veodl 1.12.0 → 2.0.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +183 -100
  3. package/bin/veo.js +47 -2
  4. package/docs/AGENT_GUIDE.md +1 -0
  5. package/native/android-arm64/veo +0 -0
  6. package/native/darwin-arm64/veo +0 -0
  7. package/native/darwin-x64/veo +0 -0
  8. package/native/linux-arm64/veo +0 -0
  9. package/native/linux-x64/veo +0 -0
  10. package/native/win32-arm64/veo.exe +0 -0
  11. package/native/win32-x64/veo.exe +0 -0
  12. package/package.json +53 -61
  13. package/src/alias.js +0 -258
  14. package/src/backend-update.js +0 -191
  15. package/src/backend.js +0 -548
  16. package/src/changes.js +0 -278
  17. package/src/cli.js +0 -781
  18. package/src/compatibility.js +0 -39
  19. package/src/config-clipboard.js +0 -67
  20. package/src/config-diagnostics.js +0 -155
  21. package/src/config-editor.js +0 -404
  22. package/src/config-errors.js +0 -64
  23. package/src/config-reset.js +0 -39
  24. package/src/config-template.js +0 -227
  25. package/src/config.js +0 -307
  26. package/src/disk-space.js +0 -68
  27. package/src/doctor.js +0 -302
  28. package/src/download-cache.js +0 -31
  29. package/src/downloader.js +0 -669
  30. package/src/execution.js +0 -68
  31. package/src/experimental-fragments.js +0 -29
  32. package/src/flush.js +0 -66
  33. package/src/history.js +0 -173
  34. package/src/inline-region.js +0 -72
  35. package/src/inspect-media.js +0 -179
  36. package/src/interactive.js +0 -120
  37. package/src/jobs.js +0 -218
  38. package/src/legacy-config-comments.js +0 -106
  39. package/src/naming.js +0 -54
  40. package/src/open-file.js +0 -15
  41. package/src/option-suggestions.js +0 -43
  42. package/src/output.js +0 -81
  43. package/src/path-links.js +0 -53
  44. package/src/paths.js +0 -26
  45. package/src/playlist.js +0 -31
  46. package/src/progress.js +0 -341
  47. package/src/run-archive.js +0 -148
  48. package/src/runs.js +0 -346
  49. package/src/source-discovery.js +0 -303
  50. package/src/state.js +0 -27
  51. package/src/stats.js +0 -63
  52. package/src/terminal-size.js +0 -8
  53. package/src/terminal-title.js +0 -19
  54. package/src/tool-setup.js +0 -151
  55. package/src/uninstall.js +0 -222
  56. package/src/updater.js +0 -229
  57. package/src/utils.js +0 -208
  58. package/src/version.js +0 -38
package/src/stats.js DELETED
@@ -1,63 +0,0 @@
1
- import { commandOutput } from './output.js';
2
- import { randomUUID } from 'node:crypto';
3
- import { readdir, lstat, rm } from 'node:fs/promises';
4
- import path from 'node:path';
5
- import { cacheBase } from './paths.js';
6
- import { readJson, writeJson } from './state.js';
7
-
8
- const fields = ['videos', 'audio', 'failed', 'skipped', 'cancelled', 'elapsedMs'];
9
- const pattern = /^[a-f0-9-]{36}\.json$/;
10
- const empty = () => Object.fromEntries(fields.map(key => [key, 0]));
11
-
12
- export function createStatsRecorder(root = cacheBase()) {
13
- const file = path.join(root, 'stats', `${randomUUID()}.json`);
14
- const totals = { version: 1, since: new Date().toISOString(), ...empty() };
15
- return async delta => {
16
- for (const key of fields) totals[key] += delta[key] || 0;
17
- await writeJson(file, totals);
18
- };
19
- }
20
-
21
- async function statFiles(root) {
22
- const directory = path.resolve(root, 'stats');
23
- const info = await lstat(directory).catch(error => { if (error.code === 'ENOENT') return null; throw error; });
24
- if (!info) return [];
25
- if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(`Invalid statistics directory: ${directory}`);
26
- return (await readdir(directory, { withFileTypes: true }))
27
- .filter(entry => entry.isFile() && pattern.test(entry.name)).map(entry => path.join(directory, entry.name));
28
- }
29
-
30
- export async function readStats(root = cacheBase()) {
31
- const result = { since: null, ...empty() };
32
- for (const file of await statFiles(root)) {
33
- const value = await readJson(file, null);
34
- if (!value) continue;
35
- if (value.version !== 1 || !Number.isFinite(Date.parse(value.since)) || fields.some(key => !Number.isFinite(value[key]) || value[key] < 0)) {
36
- throw new Error(`Invalid statistics file: ${file}`);
37
- }
38
- if (!result.since || value.since < result.since) result.since = value.since;
39
- for (const key of fields) result[key] += value[key];
40
- }
41
- return result;
42
- }
43
-
44
- // Called by flush only after registered runs have stopped and while its gate is held.
45
- export async function resetStats(root = cacheBase()) {
46
- for (const file of await statFiles(root)) await rm(file, { force: true });
47
- }
48
-
49
- export async function statsMain(args = [], { stdout = process.stdout, root = cacheBase() } = {}) {
50
- [args, stdout] = commandOutput(args, stdout);
51
- if (args.length === 1 && ['--help', '-h'].includes(args[0])) {
52
- stdout.write('veo stats [--json]\n\nShow recorded download totals. Time includes preparation, processing and saving,\nincluding failed attempts. Parallel run times are added together.\nStats start with this version; old downloads are not imported.\nUse veo flush --stats to clear temporary data and reset statistics.\n');
53
- return 0;
54
- }
55
- if (args.length && (args.length !== 1 || args[0] !== '--json')) throw new Error('Usage: veo stats [--json]');
56
- const stats = await readStats(root);
57
- if (args[0] === '--json') stdout.write(`${JSON.stringify(stats)}\n`);
58
- else {
59
- const seconds = Math.floor(stats.elapsedMs / 1000);
60
- stdout.write(`veo stats\n\nTracking since: ${stats.since || 'No downloads recorded yet'}\nVideos saved: ${stats.videos}\nAudio saved: ${stats.audio}\nTotal failures: ${stats.failed}\nSkipped: ${stats.skipped}\nCancelled: ${stats.cancelled}\nDownload time: ${Math.floor(seconds / 3600)}h ${Math.floor(seconds / 60) % 60}m ${seconds % 60}s\n\nTime includes preparation, processing and saving. Active requests appear when finished.\n`);
61
- }
62
- return 0;
63
- }
@@ -1,8 +0,0 @@
1
- // Windows stderr can retain an old size between writes. Refresh the native TTY
2
- // before reading it; custom/test streams retain their own live columns getter.
3
- export function terminalColumns(stream) {
4
- if (process.platform === 'win32' && (stream === process.stdout || stream === process.stderr)) {
5
- try { stream._refreshSize?.(); } catch { /* Cosmetic fallback only. */ }
6
- }
7
- return Number.isInteger(stream.columns) && stream.columns > 0 ? stream.columns : 80;
8
- }
@@ -1,19 +0,0 @@
1
- import { cleanText } from './utils.js';
2
-
3
- // PowerShell's console title API on Windows; OSC 0 on xterm-compatible Unix
4
- // terminals. Never put escape sequences into redirected output or dumb terminals.
5
- export function createTerminalTitle(stream, { platform = process.platform, env = process.env, processInfo = process } = {}) {
6
- let previous;
7
- return title => {
8
- if (!stream.isTTY || env.TERM === 'dumb') return;
9
- const safe = cleanText(title).slice(0, 240);
10
- if (safe === previous) return;
11
- try {
12
- if (platform === 'win32') processInfo.title = safe;
13
- else stream.write(`\x1b]0;${safe}\x07`);
14
- previous = safe;
15
- } catch {
16
- // Cosmetic only: a terminal that rejects titles must not break downloads.
17
- }
18
- };
19
- }
package/src/tool-setup.js DELETED
@@ -1,151 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- import { access, chmod, mkdtemp, realpath, rm, stat } from 'node:fs/promises';
3
- import path from 'node:path';
4
- import { cleanText } from './utils.js';
5
-
6
- // Only fixed package names and arguments are passed to these installers.
7
- export function runSetup(command, args, {
8
- signal, env = process.env, cwd, status = () => {}, timeoutMs = 600_000,
9
- } = {}) {
10
- signal?.throwIfAborted();
11
- return new Promise((resolve, reject) => {
12
- const child = spawn(command, args, {
13
- shell: false, windowsHide: true, detached: process.platform !== 'win32',
14
- stdio: ['ignore', 'pipe', 'pipe'], env, cwd,
15
- });
16
- let output = '';
17
- let stopped;
18
- const stop = error => {
19
- if (stopped) return;
20
- stopped = error;
21
- if (process.platform === 'win32' && child.pid) {
22
- const killer = spawn('taskkill.exe', ['/PID', String(child.pid), '/T', '/F'], { shell: false, windowsHide: true, stdio: 'ignore' });
23
- killer.on('error', () => child.kill());
24
- } else {
25
- try { process.kill(-child.pid, 'SIGKILL'); } catch { child.kill('SIGKILL'); }
26
- }
27
- };
28
- const abort = () => stop(signal.reason);
29
- const timer = setTimeout(() => stop(new Error('Tool installation timed out. Retry with veo doctor fix.')), timeoutMs);
30
- const receive = chunk => {
31
- const text = cleanText(String(chunk));
32
- output = (output + text).slice(-8192);
33
- // Surface package-manager progress without taking over stdin or stdout.
34
- for (const line of text.split(/[\r\n]+/)) if (line.trim()) status(line.slice(0, 500));
35
- };
36
- child.stdout.on('data', receive);
37
- child.stderr.on('data', receive);
38
- signal?.addEventListener('abort', abort, { once: true });
39
- if (signal?.aborted) abort();
40
- const cleanup = () => { clearTimeout(timer); signal?.removeEventListener('abort', abort); };
41
- child.once('error', error => { cleanup(); reject(stopped || error); });
42
- child.once('close', code => {
43
- cleanup();
44
- if (stopped) reject(stopped);
45
- else if (code !== 0) reject(new Error(`${path.basename(command)} exited with code ${code}: ${output.trim()}`));
46
- else resolve(output);
47
- });
48
- });
49
- }
50
-
51
- export async function hasTermuxEjs({ find, run = runSetup, signal }) {
52
- const python = await find(['python', 'python3']);
53
- if (!python) return false;
54
- try {
55
- await run(python, ['-B', '-c', 'import yt_dlp_ejs'], { signal, timeoutMs: 15_000 });
56
- return true;
57
- } catch {
58
- signal?.throwIfAborted();
59
- return false;
60
- }
61
- }
62
-
63
- let termuxInstall;
64
- export async function installTermuxTools({ find, signal, status, run = runSetup, env = process.env }) {
65
- if (termuxInstall) {
66
- await termuxInstall;
67
- signal?.throwIfAborted();
68
- return;
69
- }
70
- termuxInstall = (async () => {
71
- const pkg = await find(['pkg']);
72
- if (!pkg) throw new Error('Automatic Android setup requires Termux with pkg on PATH. Install python-yt-dlp, yt-dlp-ejs and ffmpeg in Termux.');
73
- signal?.throwIfAborted();
74
- status('Installing yt-dlp, JavaScript support and FFmpeg with Termux pkg (first use)…');
75
- // pkg refreshes mirrors/package lists itself. No full system upgrade or sudo.
76
- await run(pkg, ['install', env.TERMUX_APP_PACKAGE_MANAGER === 'pacman' ? '--noconfirm' : '-y', 'python-yt-dlp', 'yt-dlp-ejs', 'ffmpeg'], {
77
- signal, status, env: { ...env, DEBIAN_FRONTEND: 'noninteractive' },
78
- });
79
- })();
80
- try { await termuxInstall; }
81
- catch (cause) {
82
- signal?.throwIfAborted();
83
- throw new Error(`Automatic Termux setup failed: ${cause.message}. Retry with veo doctor fix; if the repository needs repair, run pkg update in Termux.`, { cause });
84
- } finally { termuxInstall = undefined; }
85
- }
86
-
87
- export function mediaPackagePlan(platform = process.platform, arch = process.arch) {
88
- // Windows 11 ARM runs the upstream x64 media tools via OS emulation.
89
- const binaryArch = platform === 'win32' && arch === 'arm64' ? 'x64' : arch;
90
- const versions = {
91
- 'win32-x64': '5.1.0', 'win32-ia32': '5.1.0',
92
- 'darwin-x64': '5.1.0', 'darwin-arm64': '5.0.1',
93
- 'linux-x64': '5.2.0', 'linux-ia32': '5.2.0', 'linux-arm64': '5.2.0', 'linux-arm': '5.2.0',
94
- };
95
- const target = `${platform}-${binaryArch}`;
96
- if (!versions[target]) return undefined;
97
- return { binaryArch, probePackage: `@ffprobe-installer/${target}`, probeVersion: versions[target] };
98
- }
99
-
100
- async function npmCli(find, env) {
101
- const npm = await find(['npm']);
102
- const candidates = [
103
- env.npm_execpath,
104
- npm && await realpath(npm).catch(() => undefined),
105
- npm && path.join(path.dirname(npm), 'node_modules', 'npm', 'bin', 'npm-cli.js'),
106
- path.join(path.dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js'),
107
- path.resolve(path.dirname(process.execPath), '../lib/node_modules/npm/bin/npm-cli.js'),
108
- ];
109
- for (const candidate of candidates) {
110
- if (!candidate || path.basename(candidate) !== 'npm-cli.js') continue;
111
- if (await stat(candidate).then(info => info.isFile(), () => false)) return candidate;
112
- }
113
- throw new Error('npm was not found. Install Node.js with npm, then run veo doctor fix.');
114
- }
115
-
116
- export async function installMediaTools({
117
- directory, find, stage, signal, status, platform = process.platform, arch = process.arch,
118
- env = process.env, run = runSetup, locateNpm = npmCli,
119
- }) {
120
- const plan = mediaPackagePlan(platform, arch);
121
- if (!plan) throw new Error(`Automatic FFmpeg setup is unavailable for ${platform}/${arch}. Set VEO_FFMPEG_PATH to a directory containing ffmpeg and ffprobe.`);
122
- const cli = await locateNpm(find, env);
123
- const temporary = await mkdtemp(path.join(directory, '.media-setup-'));
124
- const suffix = platform === 'win32' ? '.exe' : '';
125
- try {
126
- status('Downloading FFmpeg and FFprobe into the veo cache (first use)…');
127
- // This is a private throwaway project, never the global package or cwd.
128
- // Ignore dependency scripts; invoke the pinned ffmpeg installer explicitly.
129
- const args = [cli, 'install', '--prefix', temporary, '--no-save', '--package-lock=false', '--ignore-scripts', '--no-audit', '--no-fund', '--global=false', 'ffmpeg-static@5.3.0', `${plan.probePackage}@${plan.probeVersion}`];
130
- if (platform === 'win32' && arch === 'arm64') args.push('--force');
131
- await run(process.execPath, args, { signal, status, cwd: temporary, env });
132
- const modules = path.join(temporary, 'node_modules');
133
- await run(process.execPath, [path.join(modules, 'ffmpeg-static', 'install.js')], {
134
- signal, status, cwd: temporary,
135
- env: { ...env, npm_config_platform: platform, npm_config_arch: plan.binaryArch, FFMPEG_BIN: '', FFMPEG_BINARY_RELEASE: 'b6.1.1' },
136
- });
137
- const ffmpeg = path.join(modules, 'ffmpeg-static', `ffmpeg${suffix}`);
138
- const ffprobe = path.join(modules, ...plan.probePackage.split('/'), `ffprobe${suffix}`);
139
- for (const file of [ffmpeg, ffprobe]) {
140
- await access(file);
141
- if (process.platform !== 'win32') await chmod(file, 0o755);
142
- await run(file, ['-version'], { signal, timeoutMs: 15_000 });
143
- }
144
- await stage(ffmpeg, path.join(directory, `ffmpeg${suffix}`), signal);
145
- await stage(ffprobe, path.join(directory, `ffprobe${suffix}`), signal);
146
- return directory;
147
- } catch (cause) {
148
- signal?.throwIfAborted();
149
- throw new Error(`Automatic FFmpeg setup failed: ${cause.message}. Retry with veo doctor fix or set VEO_FFMPEG_PATH to installed tools.`, { cause });
150
- } finally { await rm(temporary, { recursive: true, force: true }); }
151
- }
package/src/uninstall.js DELETED
@@ -1,222 +0,0 @@
1
- import path from 'node:path';
2
- import { spawn } from 'node:child_process';
3
- import { rm } from 'node:fs/promises';
4
- import { commandOutput } from './output.js';
5
- import { cacheBase } from './paths.js';
6
- import { configFile as resolveConfigFile } from './config.js';
7
- import { cleanText, readableError } from './utils.js';
8
- import { removeAlias, validateAliasName, listAliases } from './alias.js';
9
-
10
- const PACKAGE = 'veodl';
11
-
12
- export const UNINSTALL_HELP = `veo uninstall - remove veo completely or one command alias
13
-
14
- Usage:
15
- veo uninstall [-p|--prefix <name>] [--json]
16
- Remove one alias (e.g. veo uninstall -p veodl)
17
- veo uninstall [--yes] [--keep-cache] [--keep-config] [--keep-aliases] [--json]
18
- Remove everything: aliases, package, cache, config
19
- veo uninstall --help Show this help
20
-
21
- With -p/--prefix, only that alias is deleted; veo itself stays installed.
22
- Without -p, veo prints what would be removed. Add --yes to delete everything:
23
- custom wrappers created with veo alias add, the ${PACKAGE} package itself
24
- (commands veo, veodl) with npm, veo's cache directory (downloads, jobs,
25
- backend tools, history, statistics) and the config file. Use --keep-cache,
26
- --keep-config or --keep-aliases to preserve one part. The config file is
27
- deleted by default; its path is shown before and after.
28
- `;
29
-
30
- export function npmUninstallCommand({ platform = process.platform } = {}) {
31
- const args = ['uninstall', '-g', PACKAGE];
32
- if (platform === 'win32') {
33
- return {
34
- command: 'cmd.exe',
35
- args: ['/d', '/s', '/c', `npm ${args.join(' ')}`],
36
- shell: false,
37
- windowsVerbatimArguments: true,
38
- };
39
- }
40
- return { command: 'npm', args, shell: false };
41
- }
42
-
43
- export function runNpmUninstall({ spawnImpl = spawn, platform = process.platform, signal, timeoutMs = 600_000 } = {}) {
44
- const { command, args, ...spawnOptions } = npmUninstallCommand({ platform });
45
- return new Promise((resolve, reject) => {
46
- const child = spawnImpl(command, args, { ...spawnOptions, stdio: 'inherit', windowsHide: true, signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs) });
47
- child.once('error', reject);
48
- child.once('close', resolve);
49
- });
50
- }
51
-
52
- function parseUninstallArgs(args) {
53
- let prefix;
54
- let yes = false;
55
- let keepCache = false;
56
- let keepConfig = false;
57
- let keepAliases = false;
58
- let json = false;
59
- let binDir;
60
- const rest = [];
61
- for (let index = 0; index < args.length; index++) {
62
- const token = args[index];
63
- if (token === '-p' || token === '--prefix') {
64
- prefix = args[++index];
65
- if (!prefix) throw new Error('--prefix requires an alias name. Use: veo uninstall -p veodl');
66
- } else if (token.startsWith('-p=')) {
67
- prefix = token.slice(3) || undefined;
68
- if (!prefix) throw new Error('--prefix requires an alias name. Use: veo uninstall -p veodl');
69
- } else if (token.startsWith('--prefix=')) {
70
- prefix = token.slice(9) || undefined;
71
- if (!prefix) throw new Error('--prefix requires an alias name. Use: veo uninstall -p veodl');
72
- } else if (token === '--yes') yes = true;
73
- else if (token === '--purge') {
74
- // Deprecated: full cleanup is now the default. Kept so older commands keep working.
75
- } else if (token === '--keep-cache') keepCache = true;
76
- else if (token === '--keep-config') keepConfig = true;
77
- else if (token === '--keep-aliases') keepAliases = true;
78
- else if (token === '--json') json = true;
79
- else if (token === '--bin-dir') {
80
- binDir = args[++index];
81
- if (!binDir) throw new Error('--bin-dir requires a directory.');
82
- } else if (token.startsWith('--bin-dir=')) {
83
- binDir = token.slice(10) || undefined;
84
- if (!binDir) throw new Error('--bin-dir requires a directory.');
85
- } else rest.push(token);
86
- }
87
- return { prefix, yes, keepCache, keepConfig, keepAliases, json, binDir, rest };
88
- }
89
-
90
- export async function uninstallMain(args = [], {
91
- stdout = process.stdout,
92
- stderr = process.stderr,
93
- platform = process.platform,
94
- env = process.env,
95
- spawnImpl = spawn,
96
- rmImpl = rm,
97
- cacheRoot,
98
- configFile,
99
- listImpl = listAliases,
100
- removeImpl = removeAlias,
101
- } = {}) {
102
- [args, stdout, stderr] = commandOutput(args, stdout, stderr);
103
- const { prefix, yes, keepCache, keepConfig, keepAliases, json, binDir, rest } = parseUninstallArgs(args);
104
- if (rest.includes('-h') || rest.includes('--help')) {
105
- stdout.write(UNINSTALL_HELP);
106
- return 0;
107
- }
108
- if (rest.length) throw new Error(`Unknown option for veo uninstall: ${rest.join(' ')}. Use: veo uninstall --help`);
109
-
110
- if (prefix) {
111
- if (keepCache || keepConfig || keepAliases) throw new Error('--keep-* cannot be combined with --prefix. Remove one alias or uninstall veo itself.');
112
- const valid = validateAliasName(prefix);
113
- const removed = await removeImpl(valid, { binDir, platform, env });
114
- if (json) {
115
- stdout.write(`${JSON.stringify({ status: 'removed', ...removed })}\n`);
116
- return 0;
117
- }
118
- stdout.write(`Alias removed: ${removed.name} (${removed.removed.length} file(s) in ${removed.binDir})\n`);
119
- if (removed.builtin) stdout.write('Note: veo update recreates the shipped veodl name.\n');
120
- return 0;
121
- }
122
-
123
- const cache = cacheRoot || cacheBase({ platform, env });
124
- const config = configFile || resolveConfigFile({ platform, env });
125
- const manual = `npm uninstall -g ${PACKAGE}`;
126
-
127
- // Custom wrappers first so the plan names them; npm removes veo/veodl itself.
128
- let customAliases = [];
129
- let aliasDir = binDir ? path.resolve(binDir) : null;
130
- try {
131
- const listed = await listImpl({ binDir: binDir || undefined, platform, env });
132
- aliasDir = listed.binDir;
133
- customAliases = listed.aliases.filter(entry => entry.present && entry.managed && !entry.builtin).map(entry => entry.name);
134
- } catch {
135
- // No bin directory (e.g. running from source without a global install):
136
- // npm uninstall still works, alias cleanup is reported as skipped.
137
- }
138
-
139
- if (!yes) {
140
- if (json) {
141
- stdout.write(`${JSON.stringify({ status: 'planned', package: PACKAGE, manual, aliases: customAliases, binDir: aliasDir, cache, config })}\n`);
142
- return 0;
143
- }
144
- stdout.write(`This removes everything: the ${PACKAGE} package with npm (commands veo, veodl).\n`);
145
- if (!keepAliases) {
146
- stdout.write(customAliases.length
147
- ? `Custom wrappers to delete: ${customAliases.join(', ')} (${aliasDir})\n`
148
- : `Custom wrappers: none found${aliasDir ? ` (${aliasDir})` : ''}.\n`);
149
- }
150
- if (!keepCache) stdout.write(`Cache to delete: ${cache}\n`);
151
- if (!keepConfig) stdout.write(`Config to delete: ${config}\n`);
152
- if (keepCache || keepConfig || keepAliases) {
153
- const kept = [
154
- keepAliases && 'aliases',
155
- keepCache && 'cache',
156
- keepConfig && 'config',
157
- ].filter(Boolean).join(', ');
158
- stdout.write(`Kept: ${kept}.\n`);
159
- }
160
- const keepFlags = `${keepAliases ? ' --keep-aliases' : ''}${keepCache ? ' --keep-cache' : ''}${keepConfig ? ' --keep-config' : ''}`;
161
- stdout.write(`Run with --yes to proceed: veo uninstall --yes${keepFlags}\n`);
162
- stdout.write(`Manual command: ${manual}\n`);
163
- return 0;
164
- }
165
-
166
- let code;
167
- try {
168
- stdout.write(`Uninstalling ${PACKAGE} with npm…\n`);
169
- code = await runNpmUninstall({ spawnImpl, platform, signal: AbortSignal.timeout(600_000) });
170
- } catch (error) {
171
- const reason = error.code === 'ENOENT' ? 'npm was not found. Install Node.js/npm, or uninstall manually.' : `Could not run npm: ${readableError(error)}`;
172
- stderr.write(`veo: ${reason}\nManual command: ${manual}\n`);
173
- return 1;
174
- }
175
- if (code !== 0) {
176
- stderr.write(`veo: npm exited with code ${code}. Uninstall manually with: ${manual}\n`);
177
- return 1;
178
- }
179
-
180
- const removedAliases = [];
181
- if (!keepAliases) {
182
- for (const name of customAliases) {
183
- try {
184
- await removeImpl(name, { binDir: aliasDir, platform, env });
185
- removedAliases.push(name);
186
- } catch (error) {
187
- stderr.write(`veo: removed the package but could not delete alias ${name}: ${readableError(error)}\n`);
188
- return 1;
189
- }
190
- }
191
- }
192
- let cacheDeleted = false;
193
- if (!keepCache) {
194
- try {
195
- await rmImpl(cache, { recursive: true, force: true });
196
- cacheDeleted = true;
197
- } catch (error) {
198
- stderr.write(`veo: removed the package but could not delete the cache ${cache}: ${readableError(error)}\n`);
199
- return 1;
200
- }
201
- }
202
- let configDeleted = false;
203
- if (!keepConfig) {
204
- try {
205
- await rmImpl(config, { force: true });
206
- configDeleted = true;
207
- } catch (error) {
208
- stderr.write(`veo: removed the package but could not delete the config ${config}: ${readableError(error)}\n`);
209
- return 1;
210
- }
211
- }
212
- if (json) {
213
- stdout.write(`${JSON.stringify({ status: 'uninstalled', package: PACKAGE, aliases: removedAliases, binDir: aliasDir, cacheDeleted, cache, configDeleted, config })}\n`);
214
- return 0;
215
- }
216
- stdout.write(`veo uninstalled (${PACKAGE}).`);
217
- if (!keepAliases) stdout.write(removedAliases.length ? ` Aliases deleted: ${removedAliases.join(', ')}.` : ' No custom wrappers found.');
218
- stdout.write(cacheDeleted ? ` Cache deleted: ${cache}.` : ` Cache kept: ${cache}.`);
219
- stdout.write(configDeleted ? ` Config deleted: ${config}.` : ` Config kept: ${config}.`);
220
- stdout.write('\n');
221
- return 0;
222
- }