@seavideo/cli 0.3.0 → 0.3.3

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 (46) hide show
  1. package/README.md +92 -452
  2. package/README.publish.md +169 -0
  3. package/dist/skills/seavideo-canvas-tools/SKILL.md +324 -0
  4. package/dist/skills/seavideo-command/SKILL.md +215 -0
  5. package/dist/skills/seavideo-prompt-design/SKILL.md +735 -0
  6. package/dist/skills/seavideo-setup/SKILL.md +195 -0
  7. package/dist/skills/seavideo-setup/references/agents/claude-code.md +31 -0
  8. package/dist/skills/seavideo-setup/references/agents/codex.md +28 -0
  9. package/dist/skills/seavideo-setup/references/authentication.md +69 -0
  10. package/dist/skills/seavideo-setup/references/install-skills.md +68 -0
  11. package/dist/skills/seavideo-setup/references/install.md +92 -0
  12. package/dist/skills/seavideo-setup/references/platforms/linux.md +29 -0
  13. package/dist/skills/seavideo-setup/references/platforms/macos.md +31 -0
  14. package/dist/skills/seavideo-setup/references/platforms/windows.md +55 -0
  15. package/dist/skills/seavideo-setup/references/troubleshooting.md +69 -0
  16. package/dist/skills/seavideo-setup/scripts/install-cli.ps1 +109 -0
  17. package/dist/skills/seavideo-setup/scripts/install-cli.sh +89 -0
  18. package/dist/skills/seavideo-setup/scripts/install-skills.mjs +130 -0
  19. package/dist/skills/seavideo-setup/scripts/preflight.ps1 +60 -0
  20. package/dist/skills/seavideo-setup/scripts/preflight.sh +25 -0
  21. package/dist/skills/seavideo-setup/scripts/setup.ps1 +74 -0
  22. package/dist/skills/seavideo-setup/scripts/setup.sh +78 -0
  23. package/dist/skills/seavideo-workflow-draft/SKILL.md +203 -0
  24. package/dist/skills/seavideo-workflow-image/SKILL.md +283 -0
  25. package/dist/skills/seavideo-workflow-video/SKILL.md +352 -0
  26. package/dist/src/agent-skills/agents.js +62 -0
  27. package/dist/src/agent-skills/backup.js +17 -0
  28. package/dist/src/agent-skills/install.js +155 -0
  29. package/dist/src/agent-skills/manifest.js +68 -0
  30. package/dist/src/agent-skills/payload.js +46 -0
  31. package/dist/src/agent-skills/store.js +38 -0
  32. package/dist/src/canvas/browser.js +5 -0
  33. package/dist/src/canvas/launch.js +77 -42
  34. package/dist/src/canvas/lifecycle.js +21 -4
  35. package/dist/src/canvas/puppeteer.js +56 -6
  36. package/dist/src/cli/commands/agent-skills.js +249 -0
  37. package/dist/src/cli/commands/canvas/session.js +3 -1
  38. package/dist/src/cli/main.js +36 -6
  39. package/dist/src/cli/program.js +27 -2
  40. package/dist/src/cli/session.js +2 -0
  41. package/dist/src/deps.js +6 -1
  42. package/dist/src/i18n.js +86 -2
  43. package/dist/src/update/check-cache.js +0 -1
  44. package/dist/src/update/notify.js +6 -4
  45. package/dist/src/update/passive.js +9 -17
  46. package/package.json +4 -11
@@ -0,0 +1,109 @@
1
+ [CmdletBinding()]
2
+ param(
3
+ [switch] $Upgrade,
4
+
5
+ [switch] $Uninstall,
6
+
7
+ [switch] $Purge,
8
+
9
+ [string] $Registry
10
+ )
11
+
12
+ $ErrorActionPreference = 'Stop'
13
+
14
+ function Find-Application {
15
+ param(
16
+ [Parameter(Mandatory = $true)]
17
+ [string[]] $Names
18
+ )
19
+
20
+ foreach ($name in $Names) {
21
+ $command = Get-Command $name -CommandType Application -ErrorAction SilentlyContinue |
22
+ Select-Object -First 1
23
+ if ($null -ne $command) {
24
+ return $command.Source
25
+ }
26
+ }
27
+
28
+ return $null
29
+ }
30
+
31
+ if ($Upgrade -and $Uninstall) {
32
+ Write-Error '-Upgrade and -Uninstall are mutually exclusive.'
33
+ exit 2
34
+ }
35
+
36
+ if ($Purge -and -not $Uninstall) {
37
+ Write-Error '-Purge only applies to -Uninstall.'
38
+ exit 2
39
+ }
40
+
41
+ $node = Find-Application @('node.exe', 'node')
42
+ $npm = Find-Application @('npm.cmd', 'npm.exe')
43
+ $seavideo = Find-Application @('seavideo.cmd', 'seavideo.exe')
44
+
45
+ if ($Uninstall) {
46
+ if ($null -eq $npm) {
47
+ Write-Error 'npm is required to uninstall @seavideo/cli.'
48
+ exit 1
49
+ }
50
+ Write-Output 'Uninstalling @seavideo/cli globally...'
51
+ & $npm uninstall -g '@seavideo/cli'
52
+ if ($LASTEXITCODE -ne 0) {
53
+ Write-Error "npm uninstall failed with exit code $LASTEXITCODE."
54
+ exit $LASTEXITCODE
55
+ }
56
+ # 默认保留 ~/.seavideo:里面有多环境配置与安装清单,删掉等于让用户重配。
57
+ # -Purge 是显式意图,才动它。
58
+ $configDir = Join-Path $HOME '.seavideo'
59
+ if ($Purge) {
60
+ Write-Output "Removing $configDir ..."
61
+ Remove-Item -LiteralPath $configDir -Recurse -Force -ErrorAction SilentlyContinue
62
+ }
63
+ else {
64
+ Write-Output "Kept $configDir (use -Purge to delete configurations and the skills manifest)"
65
+ }
66
+ exit 0
67
+ }
68
+
69
+ if ($null -eq $node -or $null -eq $npm) {
70
+ Write-Error 'Node and npm are required before installing @seavideo/cli.'
71
+ exit 1
72
+ }
73
+
74
+ if ($null -ne $seavideo -and -not $Upgrade) {
75
+ Write-Output "seavideo is already available: $seavideo"
76
+ Write-Output 'Run with -Upgrade to install the latest version explicitly.'
77
+ exit 0
78
+ }
79
+
80
+ $package = '@seavideo/cli'
81
+ if ($Upgrade) {
82
+ $package = '@seavideo/cli@latest'
83
+ }
84
+
85
+ Write-Output "Installing $package globally..."
86
+ if ([string]::IsNullOrWhiteSpace($Registry)) {
87
+ & $npm install -g $package
88
+ } else {
89
+ & $npm install -g $package --registry $Registry
90
+ }
91
+ if ($LASTEXITCODE -ne 0) {
92
+ Write-Error "npm install failed with exit code $LASTEXITCODE."
93
+ exit $LASTEXITCODE
94
+ }
95
+
96
+ Write-Output ''
97
+ Write-Output 'Verifying installation...'
98
+
99
+ $installed = Find-Application @('seavideo.cmd', 'seavideo.exe')
100
+ if ($null -eq $installed) {
101
+ Write-Error 'seavideo was installed but is not available on PATH. Run npm prefix -g and add its command directory to PATH.'
102
+ exit 1
103
+ }
104
+
105
+ & $installed --version
106
+ if ($LASTEXITCODE -ne 0) {
107
+ Write-Error "seavideo --version failed with exit code $LASTEXITCODE."
108
+ exit $LASTEXITCODE
109
+ }
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env bash
2
+ set -eu
3
+
4
+ usage() {
5
+ printf 'Usage: %s [--upgrade | --uninstall] [--registry URL] [--purge]\n' "$0"
6
+ }
7
+
8
+ upgrade=0
9
+ uninstall=0
10
+ purge=0
11
+ registry=''
12
+ while [ "$#" -gt 0 ]; do
13
+ case "$1" in
14
+ --upgrade) upgrade=1 ;;
15
+ --uninstall) uninstall=1 ;;
16
+ --purge) purge=1 ;;
17
+ --registry)
18
+ shift
19
+ if [ "$#" -eq 0 ] || [ -z "$1" ]; then
20
+ printf '%s\n' '--registry requires a URL' >&2
21
+ usage >&2
22
+ exit 2
23
+ fi
24
+ registry="$1"
25
+ ;;
26
+ -h|--help) usage; exit 0 ;;
27
+ *) printf 'Unknown argument: %s\n' "$1" >&2; usage >&2; exit 2 ;;
28
+ esac
29
+ shift
30
+ done
31
+
32
+ if [ "$upgrade" -eq 1 ] && [ "$uninstall" -eq 1 ]; then
33
+ printf '%s\n' '--upgrade and --uninstall are mutually exclusive' >&2
34
+ usage >&2
35
+ exit 2
36
+ fi
37
+
38
+ if [ "$purge" -eq 1 ] && [ "$uninstall" -eq 0 ]; then
39
+ printf '%s\n' '--purge only applies to --uninstall' >&2
40
+ usage >&2
41
+ exit 2
42
+ fi
43
+
44
+ if [ "$uninstall" -eq 1 ]; then
45
+ if ! command -v npm >/dev/null 2>&1; then
46
+ printf 'npm is required to uninstall @seavideo/cli.\n' >&2
47
+ exit 1
48
+ fi
49
+ printf 'Uninstalling @seavideo/cli globally...\n'
50
+ npm uninstall -g @seavideo/cli
51
+ # 默认保留 ~/.seavideo:里面有多环境配置与安装清单,删掉等于让用户重配。
52
+ # --purge 是显式意图,才动它。
53
+ if [ "$purge" -eq 1 ]; then
54
+ printf 'Removing ~/.seavideo ...\n'
55
+ rm -rf "$HOME/.seavideo"
56
+ else
57
+ printf 'Kept %s (use --purge to delete configurations and the skills manifest)\n' "$HOME/.seavideo"
58
+ fi
59
+ exit 0
60
+ fi
61
+
62
+ if command -v seavideo >/dev/null 2>&1 && [ "$upgrade" -eq 0 ]; then
63
+ printf 'seavideo is already available: %s\n' "$(command -v seavideo)"
64
+ printf 'Run with --upgrade to install the latest version explicitly.\n'
65
+ exit 0
66
+ fi
67
+
68
+ if ! command -v node >/dev/null 2>&1 || ! command -v npm >/dev/null 2>&1; then
69
+ printf 'Node and npm are required before installing @seavideo/cli.\n' >&2
70
+ exit 1
71
+ fi
72
+
73
+ printf 'Installing @seavideo/cli globally...\n'
74
+ if [ "$upgrade" -eq 1 ]; then
75
+ if [ -n "$registry" ]; then
76
+ npm install -g @seavideo/cli@latest --registry "$registry"
77
+ else
78
+ npm install -g @seavideo/cli@latest
79
+ fi
80
+ else
81
+ if [ -n "$registry" ]; then
82
+ npm install -g @seavideo/cli --registry "$registry"
83
+ else
84
+ npm install -g @seavideo/cli
85
+ fi
86
+ fi
87
+
88
+ printf '\nVerifying installation...\n'
89
+ seavideo --version
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { cp, mkdir, realpath, rm } from 'node:fs/promises';
4
+ import { homedir } from 'node:os';
5
+ import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import process from 'node:process';
8
+
9
+ const PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
10
+
11
+ /** 引导技能在目标目录里的名字。 */
12
+ const GUIDE_NAME = 'seavideo-setup';
13
+
14
+ /** 改名前的旧名字。不清掉它,Agent 会同时加载两份安装说明。 */
15
+ const LEGACY_GUIDE_NAME = 'seavideo-skill';
16
+
17
+ function usage() {
18
+ console.log(`Usage: node scripts/install-skills.mjs --agent <agent> [options]
19
+
20
+ Agents:
21
+ codex
22
+ claude-code
23
+
24
+ Options:
25
+ --scope <user|project> Install scope. Default: user
26
+ --project <path> Project root for --scope project. Default: current directory
27
+ --dry-run Print targets without writing files
28
+ --help Show this help`);
29
+ }
30
+
31
+ function parseArgs(argv) {
32
+ const options = { scope: 'user', project: process.cwd(), dryRun: false };
33
+ for (let index = 0; index < argv.length; index += 1) {
34
+ const arg = argv[index];
35
+ if (arg === '--agent') options.agent = argv[++index];
36
+ else if (arg === '--scope') options.scope = argv[++index];
37
+ else if (arg === '--project') options.project = argv[++index];
38
+ else if (arg === '--dry-run') options.dryRun = true;
39
+ else if (arg === '--help' || arg === '-h') options.help = true;
40
+ else throw new Error(`Unknown argument: ${arg}`);
41
+ }
42
+ return options;
43
+ }
44
+
45
+ export function destinationFor(options) {
46
+ if (!['user', 'project'].includes(options.scope)) {
47
+ throw new Error('--scope must be "user" or "project"');
48
+ }
49
+ const user = options.home ?? homedir();
50
+ const project = resolve(options.project);
51
+ const paths = {
52
+ codex: {
53
+ user: join(options.env?.CODEX_HOME || join(user, '.codex'), 'skills'),
54
+ project: join(project, '.agents', 'skills'),
55
+ },
56
+ 'claude-code': {
57
+ user: join(user, '.claude', 'skills'),
58
+ project: join(project, '.claude', 'skills'),
59
+ },
60
+ };
61
+ const target = paths[options.agent]?.[options.scope];
62
+ if (!target) throw new Error('--agent must be "codex" or "claude-code"');
63
+ return target;
64
+ }
65
+
66
+ async function replaceDirectory(source, destination) {
67
+ await rm(destination, { recursive: true, force: true });
68
+ await cp(source, destination, { recursive: true, force: true });
69
+ }
70
+
71
+ async function realPathOrSelf(path) {
72
+ try {
73
+ return await realpath(path);
74
+ } catch {
75
+ return path;
76
+ }
77
+ }
78
+
79
+ /**
80
+ * 本包只安装引导技能自身。
81
+ *
82
+ * 业务技能不再随包分发:它们是 npm 包 `dist/skills/` 的一部分,装好 CLI 后由
83
+ * `seavideo agent-skills add` 安装。这样技能升级跟 CLI 版本走,不会出现
84
+ * 「解压的包是 0.2、CLI 是 0.3」这种两份内容并存的情况。
85
+ */
86
+ export async function install(destination, dryRun) {
87
+ const target = resolve(destination);
88
+ const source = resolve(PACKAGE_ROOT);
89
+ const sourceToTarget = relative(source, target);
90
+ if (sourceToTarget === '' || (!sourceToTarget.startsWith('..') && !isAbsolute(sourceToTarget))) {
91
+ throw new Error('Refusing to install inside the package itself');
92
+ }
93
+
94
+ console.log(`Agent skill root: ${target}`);
95
+ if (dryRun) {
96
+ console.log(`would install ${GUIDE_NAME}`);
97
+ return;
98
+ }
99
+
100
+ await mkdir(target, { recursive: true });
101
+ const guideTarget = join(target, GUIDE_NAME);
102
+ if ((await realPathOrSelf(guideTarget)) !== (await realPathOrSelf(source))) {
103
+ await replaceDirectory(source, guideTarget);
104
+ }
105
+ // 旧名字的副本留着会被 Agent 当成第二个安装技能,且内容是旧版本。
106
+ // force: true 让「本来就没有」也是一次成功的空操作。
107
+ await rm(join(target, LEGACY_GUIDE_NAME), { recursive: true, force: true });
108
+ console.log(`installed ${GUIDE_NAME}`);
109
+ console.log('Business Skills are installed by the CLI: seavideo agent-skills add');
110
+ }
111
+
112
+ async function main() {
113
+ const options = parseArgs(process.argv.slice(2));
114
+ if (options.help) return usage();
115
+ if (!options.agent) throw new Error('--agent is required');
116
+
117
+ const destination = destinationFor({
118
+ ...options,
119
+ env: process.env,
120
+ });
121
+ await install(destination, options.dryRun);
122
+ }
123
+
124
+ const entrypoint = process.argv[1] ? resolve(process.argv[1]) : '';
125
+ if (entrypoint === fileURLToPath(import.meta.url)) {
126
+ main().catch((error) => {
127
+ console.error(`install-skills failed: ${error.message}`);
128
+ process.exitCode = 1;
129
+ });
130
+ }
@@ -0,0 +1,60 @@
1
+ [CmdletBinding()]
2
+ param()
3
+
4
+ $ErrorActionPreference = 'Stop'
5
+
6
+ function Find-Application {
7
+ param(
8
+ [Parameter(Mandatory = $true)]
9
+ [string[]] $Names
10
+ )
11
+
12
+ foreach ($name in $Names) {
13
+ $command = Get-Command $name -CommandType Application -ErrorAction SilentlyContinue |
14
+ Select-Object -First 1
15
+ if ($null -ne $command) {
16
+ return $command.Source
17
+ }
18
+ }
19
+
20
+ return $null
21
+ }
22
+
23
+ function Invoke-ReadOnly {
24
+ param(
25
+ [Parameter(Mandatory = $true)]
26
+ [string] $Executable,
27
+
28
+ [Parameter(Mandatory = $true)]
29
+ [string[]] $Arguments
30
+ )
31
+
32
+ $output = & $Executable @Arguments 2>&1 | Out-String
33
+ return $output.Trim()
34
+ }
35
+
36
+ Write-Output '== Seavideo preflight =='
37
+
38
+ $node = Find-Application @('node.exe', 'node')
39
+ if ($null -eq $node) {
40
+ Write-Output 'node: missing'
41
+ } else {
42
+ Write-Output "node: $(Invoke-ReadOnly $node @('--version'))"
43
+ }
44
+
45
+ $npm = Find-Application @('npm.cmd', 'npm.exe')
46
+ if ($null -eq $npm) {
47
+ Write-Output 'npm: missing'
48
+ } else {
49
+ Write-Output "npm: $(Invoke-ReadOnly $npm @('--version'))"
50
+ }
51
+
52
+ $seavideo = Find-Application @('seavideo.cmd', 'seavideo.exe')
53
+ if ($null -eq $seavideo) {
54
+ Write-Output 'seavideo: missing'
55
+ } else {
56
+ Write-Output "seavideo: $seavideo"
57
+ Write-Output "version: $(Invoke-ReadOnly $seavideo @('--version'))"
58
+ Write-Output "environment: $(Invoke-ReadOnly $seavideo @('env', 'current'))"
59
+ Write-Output "authentication: $(Invoke-ReadOnly $seavideo @('auth', 'status'))"
60
+ }
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ set -eu
3
+
4
+ printf '== Seavideo preflight ==\n'
5
+
6
+ if command -v node >/dev/null 2>&1; then
7
+ printf 'node: %s\n' "$(node --version)"
8
+ else
9
+ printf 'node: missing\n'
10
+ fi
11
+
12
+ if command -v npm >/dev/null 2>&1; then
13
+ printf 'npm: %s\n' "$(npm --version)"
14
+ else
15
+ printf 'npm: missing\n'
16
+ fi
17
+
18
+ if command -v seavideo >/dev/null 2>&1; then
19
+ printf 'seavideo: %s\n' "$(command -v seavideo)"
20
+ printf 'version: %s\n' "$(seavideo --version 2>&1 || true)"
21
+ printf 'environment: %s\n' "$(seavideo env current 2>&1 || true)"
22
+ printf 'authentication: %s\n' "$(seavideo auth status 2>&1 || true)"
23
+ else
24
+ printf 'seavideo: missing\n'
25
+ fi
@@ -0,0 +1,74 @@
1
+ [CmdletBinding()]
2
+ param(
3
+ [switch] $Global,
4
+
5
+ [switch] $DryRun,
6
+
7
+ [string] $Registry
8
+ )
9
+
10
+ # 一条命令把 CLI 与 Skills 装到本机已检测到的 Agent。
11
+ # 只编排已有脚本,不复制它们的逻辑:预检、装 CLI、装 Skills 三件事各自可单独跑。
12
+
13
+ $ErrorActionPreference = 'Stop'
14
+ $ScriptDir = Split-Path -Parent $PSCommandPath
15
+
16
+ function Find-Application {
17
+ param(
18
+ [Parameter(Mandatory = $true)]
19
+ [string[]] $Names
20
+ )
21
+
22
+ foreach ($name in $Names) {
23
+ $command = Get-Command $name -CommandType Application -ErrorAction SilentlyContinue |
24
+ Select-Object -First 1
25
+ if ($null -ne $command) {
26
+ return $command.Source
27
+ }
28
+ }
29
+
30
+ return $null
31
+ }
32
+
33
+ Write-Output '== Seavideo setup =='
34
+ & powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $ScriptDir 'preflight.ps1')
35
+
36
+ if ($null -eq (Find-Application @('seavideo.cmd', 'seavideo.exe'))) {
37
+ $installArgs = @{}
38
+ if (-not [string]::IsNullOrWhiteSpace($Registry)) {
39
+ $installArgs['Registry'] = $Registry
40
+ }
41
+ & powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $ScriptDir 'install-cli.ps1') @installArgs
42
+ }
43
+
44
+ $seavideo = Find-Application @('seavideo.cmd', 'seavideo.exe')
45
+ if ($null -eq $seavideo) {
46
+ Write-Error 'seavideo is still not on PATH. Add the npm global bin directory to PATH and rerun.'
47
+ exit 1
48
+ }
49
+
50
+ # 旧版本 CLI 没有 agent-skills 子命令,此时 install-cli.ps1 不会升级(它不是缺失)。
51
+ # 不显式检查,用户会看到 commander 的 unknown command,看不出该做什么。
52
+ $helpText = (& $seavideo --help 2>&1 | Out-String)
53
+ if ($helpText -notmatch 'agent-skills') {
54
+ Write-Error "The installed seavideo has no 'agent-skills' command. Run install-cli.ps1 -Upgrade first."
55
+ exit 1
56
+ }
57
+
58
+ Write-Output ''
59
+ Write-Output '== Installing Skills =='
60
+
61
+ $skillArgs = @('agent-skills', 'add')
62
+ if ($Global) {
63
+ $skillArgs += '-g'
64
+ }
65
+ if ($DryRun) {
66
+ $skillArgs += '--dry-run'
67
+ }
68
+ & $seavideo @skillArgs
69
+ if ($LASTEXITCODE -ne 0) {
70
+ Write-Error "seavideo agent-skills add failed with exit code $LASTEXITCODE."
71
+ exit $LASTEXITCODE
72
+ }
73
+
74
+ & $seavideo agent-skills list
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env bash
2
+ set -eu
3
+
4
+ # 一条命令把 CLI 与 Skills 装到本机已检测到的 Agent。
5
+ # 只编排已有脚本,不复制它们的逻辑:预检、装 CLI、装 Skills 三件事各自可单独跑。
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8
+
9
+ usage() {
10
+ printf 'Usage: %s [-g|--global] [--registry URL] [--dry-run]\n' "$0"
11
+ printf '\nInstalls @seavideo/cli when missing, then installs the bundled Skills.\n'
12
+ printf 'Default scope is the current project; -g installs to user-level Agent roots.\n'
13
+ }
14
+
15
+ scope_flag=''
16
+ registry_flag=''
17
+ dry_run=0
18
+ while [ "$#" -gt 0 ]; do
19
+ case "$1" in
20
+ -g|--global) scope_flag='-g' ;;
21
+ --registry)
22
+ shift
23
+ if [ "$#" -eq 0 ] || [ -z "$1" ]; then
24
+ printf '%s\n' '--registry requires a URL' >&2
25
+ exit 2
26
+ fi
27
+ registry_flag="$1"
28
+ ;;
29
+ -n|--dry-run) dry_run=1 ;;
30
+ -h|--help) usage; exit 0 ;;
31
+ *) printf 'Unknown argument: %s\n' "$1" >&2; usage >&2; exit 2 ;;
32
+ esac
33
+ shift
34
+ done
35
+
36
+ printf '== Seavideo setup ==\n'
37
+ bash "$SCRIPT_DIR/preflight.sh"
38
+
39
+ if ! command -v seavideo >/dev/null 2>&1; then
40
+ if [ -n "$registry_flag" ]; then
41
+ bash "$SCRIPT_DIR/install-cli.sh" --registry "$registry_flag"
42
+ else
43
+ bash "$SCRIPT_DIR/install-cli.sh"
44
+ fi
45
+ fi
46
+
47
+ if ! command -v seavideo >/dev/null 2>&1; then
48
+ printf '%s\n' 'seavideo is still not on PATH. Add the npm global bin directory to PATH and rerun.' >&2
49
+ exit 1
50
+ fi
51
+
52
+ # 旧版本 CLI 没有 agent-skills 子命令,此时 install-cli.sh 不会升级(它不是缺失)。
53
+ # 不显式检查,用户会看到 commander 的 unknown command,看不出该做什么。
54
+ # 用根帮助里的子命令清单判断,不看退出码:commander 对未知子命令只在调用时
55
+ # 才报错,`--help` 与未知命令的退出码都不可靠。
56
+ if ! seavideo --help 2>/dev/null | grep -q 'agent-skills'; then
57
+ printf '%s\n' 'The installed seavideo has no "agent-skills" command. Upgrade first:' >&2
58
+ if [ -n "$registry_flag" ]; then
59
+ printf ' bash %s/install-cli.sh --upgrade --registry %s\n' "$SCRIPT_DIR" "$registry_flag" >&2
60
+ else
61
+ printf ' bash %s/install-cli.sh --upgrade\n' "$SCRIPT_DIR" >&2
62
+ fi
63
+ exit 1
64
+ fi
65
+
66
+ printf '\n== Installing Skills ==\n'
67
+ args=''
68
+ if [ -n "$scope_flag" ]; then
69
+ args="$scope_flag"
70
+ fi
71
+ if [ "$dry_run" -eq 1 ]; then
72
+ args="$args --dry-run"
73
+ fi
74
+ # 参数刻意不加引号:空串会变成一个位置参数,被 commander 当成多余实参。
75
+ # 这里是脚本内构造的固定枚举值,不含空格与通配符。
76
+ # shellcheck disable=SC2086
77
+ seavideo agent-skills add $args
78
+ seavideo agent-skills list