siluzan-tso-cli 1.1.9-beta.3 → 1.1.11-beta.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.
- package/README.md +1 -1
- package/dist/skill/SKILL.md +8 -25
- package/dist/skill/_meta.json +2 -2
- package/dist/skill/scripts/install.ps1 +199 -0
- package/dist/skill/scripts/install.sh +214 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ siluzan-tso init -d /path/to/skills # 写入自定义目录
|
|
|
49
49
|
siluzan-tso init --force # 强制覆盖已存在文件
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
> **注意**:当前为测试版(1.1.
|
|
52
|
+
> **注意**:当前为测试版(1.1.11-beta.2),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-tso-cli`。
|
|
53
53
|
|
|
54
54
|
| 助手 | 建议 `--ai` |
|
|
55
55
|
|------|-------------|
|
package/dist/skill/SKILL.md
CHANGED
|
@@ -14,6 +14,14 @@ allowed-tools: Bash(siluzan-tso:*) Read
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
+
## 一键安装
|
|
18
|
+
|
|
19
|
+
如果 CLI 尚未安装,直接帮用户执行对应平台的安装脚本:
|
|
20
|
+
|
|
21
|
+
- **macOS / Linux / WSL:** `bash scripts/install.sh`
|
|
22
|
+
- **Windows PowerShell:** `powershell -ExecutionPolicy Bypass -File scripts/install.ps1`
|
|
23
|
+
|
|
24
|
+
脚本会自动完成 Node.js 检测/安装、CLI 安装、Skill 全局注册,并引导用户配置 API Key。无需选择,本脚本专为 siluzan-tso-cli 定制。
|
|
17
25
|
|
|
18
26
|
---
|
|
19
27
|
|
|
@@ -21,37 +29,12 @@ allowed-tools: Bash(siluzan-tso:*) Read
|
|
|
21
29
|
|
|
22
30
|
使用本 Skill 前,以下组件必须已安装并就绪:
|
|
23
31
|
|
|
24
|
-
### 必需二进制 / 运行时
|
|
25
|
-
| 依赖 | 最低版本 | 用途 |
|
|
26
|
-
|------|---------|------|
|
|
27
|
-
| **Node.js** | 18+ | CLI 执行运行时以及 `node -e` 数据过滤 |
|
|
28
|
-
| **npm** 或 **pnpm** | npm 8+ / pnpm 8+ | 安装 `siluzan-tso-cli` 全局包 |
|
|
29
|
-
| **siluzan-tso** CLI | 与 Skill 同版本 | 所有业务操作的执行入口(由 `npm install -g siluzan-tso-cli` 安装) |
|
|
30
|
-
|
|
31
|
-
### 凭据与配置文件
|
|
32
|
-
| 项目 | 位置 | 说明 |
|
|
33
|
-
|------|------|------|
|
|
34
|
-
| API Key 或 Token | `~/.siluzan/config.json` 中的 `apiKey` 或 `token` 字段 | 用于所有 TSO API 调用的鉴权。API Key 在丝路赞控制台「个人设置 → API Key 管理」创建。**请勿将此文件提交到 Git。** |
|
|
35
|
-
| tsoApiBaseUrl | `~/.siluzan/config.json` 中的 `apiBaseUrl` | TSO 后端 API 地址,默认 `https://tso-api.siluzan.com`(生产)或 `https://tso-api-ci.siluzan.com`(测试) |
|
|
36
|
-
| googleApiUrl | `~/.siluzan/config.json` 中的 `googleApiUrl` | Google 广告 API 网关,默认 `https://googleapi.mysiluzan.com`(从 tsoApiBaseUrl 自动推导) |
|
|
37
|
-
|
|
38
|
-
### 网络端点
|
|
39
|
-
本 Skill 通过 CLI 访问以下远程服务:
|
|
40
|
-
| 端点 | 用途 |
|
|
41
|
-
|------|------|
|
|
42
|
-
| `tso-api.siluzan.com` / `tso-api-ci.siluzan.com` | TSO 核心 API(账户、报告、预警、开票等) |
|
|
43
|
-
| `googleapi.mysiluzan.com` / `googleapi-ci.mysiluzan.com` | Google Ads API 网关(广告 CRUD、关键词、地理定位) |
|
|
44
|
-
| `www.siluzan.com` / `www-ci.siluzan.com` | 前端页面(充值/激活等需浏览器操作时引导用户打开) |
|
|
45
|
-
| `o605862.ingest.us.sentry.io` | 错误追踪(Sentry,仅发送匿名崩溃日志,不含业务数据) |
|
|
46
|
-
| `registry.npmjs.org` | 版本更新检查 |
|
|
47
|
-
|
|
48
32
|
### 可选环境变量
|
|
49
33
|
| 变量 | 说明 |
|
|
50
34
|
|------|------|
|
|
51
35
|
| `SILUZAN_API_KEY` | 从环境变量读取 API Key(优先级高于 config.json,CI/CD 推荐) |
|
|
52
36
|
| `SILUZAN_AUTH_TOKEN` | 从环境变量读取 JWT Token(优先级高于 config.json) |
|
|
53
37
|
| `SILUZAN_DATA_PERMISSION` | 从环境变量读取数据权限标识(优先级高于 config.json,跳过自动拉取) |
|
|
54
|
-
| `SILUZAN_GOOGLE_API` | 覆盖默认 Google API 网关地址 |
|
|
55
38
|
|
|
56
39
|
如果上述依赖缺失,请先参照 `references/setup.md` 完成安装与配置。
|
|
57
40
|
|
package/dist/skill/_meta.json
CHANGED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#Requires -Version 5.1
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# siluzan-tso-cli - One-click install script (PowerShell)
|
|
4
|
+
# Supported: Windows 10/11 (PowerShell 5.1+ or PowerShell 7+)
|
|
5
|
+
# =============================================================================
|
|
6
|
+
|
|
7
|
+
$ErrorActionPreference = 'Stop'
|
|
8
|
+
|
|
9
|
+
# -- Package info (injected at build time) ------------------------------------
|
|
10
|
+
$PKG_NAME = 'siluzan-tso-cli'
|
|
11
|
+
$CLI_BIN = 'siluzan-tso'
|
|
12
|
+
$SKILL_LABEL = 'Siluzan TSO'
|
|
13
|
+
$INSTALL_CMD = 'npm install -g siluzan-tso-cli@beta'
|
|
14
|
+
$PERMISSION_HINT = 'Assets + TSO (Ad Management)'
|
|
15
|
+
$WEB_BASE = 'https://www-ci.siluzan.com'
|
|
16
|
+
$API_KEY_URL = "$WEB_BASE/v3/foreign_trade/settings/apiKeyManagement"
|
|
17
|
+
|
|
18
|
+
# -- Constants ----------------------------------------------------------------
|
|
19
|
+
$NODE_MAJOR_MIN = 18
|
|
20
|
+
$NPM_MIRROR = 'https://registry.npmmirror.com'
|
|
21
|
+
|
|
22
|
+
# -- Helpers ------------------------------------------------------------------
|
|
23
|
+
function Write-Info { param([string]$Msg) Write-Host "[OK] $Msg" -ForegroundColor Green }
|
|
24
|
+
function Write-Warn { param([string]$Msg) Write-Host "[!] $Msg" -ForegroundColor Yellow }
|
|
25
|
+
function Write-Err { param([string]$Msg) Write-Host "[X] $Msg" -ForegroundColor Red }
|
|
26
|
+
function Write-Step { param([string]$Msg) Write-Host "`n-- $Msg --" -ForegroundColor White }
|
|
27
|
+
|
|
28
|
+
function Read-Input {
|
|
29
|
+
param([string]$Prompt)
|
|
30
|
+
Write-Host $Prompt -NoNewline
|
|
31
|
+
return [Console]::ReadLine()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function Refresh-Path {
|
|
35
|
+
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
|
|
36
|
+
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
|
|
37
|
+
$env:Path = "$machinePath;$userPath"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# -- Node.js ------------------------------------------------------------------
|
|
41
|
+
function Test-NodeVersion {
|
|
42
|
+
try {
|
|
43
|
+
$nodeCmd = Get-Command node -ErrorAction SilentlyContinue
|
|
44
|
+
if (-not $nodeCmd) { return $false }
|
|
45
|
+
$ver = (node -v) -replace '^v', ''
|
|
46
|
+
$major = [int]($ver.Split('.')[0])
|
|
47
|
+
return $major -ge $NODE_MAJOR_MIN
|
|
48
|
+
} catch {
|
|
49
|
+
return $false
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function Get-NodeVersionString {
|
|
54
|
+
try { return (node -v) } catch { return 'N/A' }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function Install-NodeJS {
|
|
58
|
+
$hasWinget = $null -ne (Get-Command winget -ErrorAction SilentlyContinue)
|
|
59
|
+
if ($hasWinget) {
|
|
60
|
+
Write-Info 'Installing Node.js LTS via winget...'
|
|
61
|
+
winget install -e --id OpenJS.NodeJS.LTS --silent --accept-package-agreements --accept-source-agreements
|
|
62
|
+
if ($LASTEXITCODE -ne 0) {
|
|
63
|
+
Write-Warn 'winget returned non-zero, trying fallback...'
|
|
64
|
+
Install-NodeFallback
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
Install-NodeFallback
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
Refresh-Path
|
|
72
|
+
if (-not (Test-NodeVersion)) {
|
|
73
|
+
Write-Warn 'Node.js not found after PATH refresh, locating install dir...'
|
|
74
|
+
$nodePath = "$env:ProgramFiles\nodejs"
|
|
75
|
+
if (Test-Path "$nodePath\node.exe") {
|
|
76
|
+
$env:Path = "$nodePath;$env:Path"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function Install-NodeFallback {
|
|
82
|
+
Write-Err 'Cannot auto-install Node.js'
|
|
83
|
+
Write-Host ''
|
|
84
|
+
Write-Host ' Please install Node.js manually:' -ForegroundColor Cyan
|
|
85
|
+
Write-Host ' https://nodejs.org/en/download/'
|
|
86
|
+
Write-Host ''
|
|
87
|
+
Write-Host ' After installation, reopen PowerShell and run this script again.'
|
|
88
|
+
throw 'Node.js is required'
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# -- Main ---------------------------------------------------------------------
|
|
92
|
+
function Main {
|
|
93
|
+
Write-Host ''
|
|
94
|
+
Write-Host '+---------------------------------------------+' -ForegroundColor White
|
|
95
|
+
Write-Host "| $SKILL_LABEL -- Install |" -ForegroundColor White
|
|
96
|
+
Write-Host '+---------------------------------------------+' -ForegroundColor White
|
|
97
|
+
Write-Host ''
|
|
98
|
+
|
|
99
|
+
# Step 1: Environment check
|
|
100
|
+
Write-Step 'Step 1/4: Environment check'
|
|
101
|
+
|
|
102
|
+
if (Test-NodeVersion) {
|
|
103
|
+
Write-Info "Node.js $(Get-NodeVersionString) found"
|
|
104
|
+
} else {
|
|
105
|
+
$nodeCmd = Get-Command node -ErrorAction SilentlyContinue
|
|
106
|
+
if ($nodeCmd) {
|
|
107
|
+
Write-Warn "Node.js $(Get-NodeVersionString) is too old (need >= $NODE_MAJOR_MIN), upgrading..."
|
|
108
|
+
} else {
|
|
109
|
+
Write-Warn 'Node.js not found, installing...'
|
|
110
|
+
}
|
|
111
|
+
Install-NodeJS
|
|
112
|
+
if (-not (Test-NodeVersion)) {
|
|
113
|
+
Write-Err 'Node.js installation failed. Please install manually: https://nodejs.org/'
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
Write-Info "Node.js $(Get-NodeVersionString) installed"
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
$npmCmd = Get-Command npm -ErrorAction SilentlyContinue
|
|
120
|
+
if (-not $npmCmd) {
|
|
121
|
+
Refresh-Path
|
|
122
|
+
$npmCmd = Get-Command npm -ErrorAction SilentlyContinue
|
|
123
|
+
}
|
|
124
|
+
if (-not $npmCmd) {
|
|
125
|
+
Write-Err 'npm not found (Node.js installation may be incomplete)'
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
Write-Info 'npm ready'
|
|
129
|
+
|
|
130
|
+
$currentRegistry = ''
|
|
131
|
+
try { $currentRegistry = (npm config get registry 2>$null).Trim() } catch {}
|
|
132
|
+
if ($currentRegistry -ne $NPM_MIRROR -and $currentRegistry -ne "$NPM_MIRROR/") {
|
|
133
|
+
Write-Info 'Switching npm registry to China mirror for faster downloads...'
|
|
134
|
+
npm config set registry $NPM_MIRROR
|
|
135
|
+
Write-Info "npm registry set to $NPM_MIRROR"
|
|
136
|
+
} else {
|
|
137
|
+
Write-Info 'npm registry already set to China mirror'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
# Step 2: Install CLI
|
|
141
|
+
Write-Step "Step 2/4: Install $PKG_NAME"
|
|
142
|
+
|
|
143
|
+
Write-Info "Running: $INSTALL_CMD"
|
|
144
|
+
Invoke-Expression $INSTALL_CMD
|
|
145
|
+
if ($LASTEXITCODE -ne 0) { Write-Err "$INSTALL_CMD failed"; return }
|
|
146
|
+
Write-Info "$PKG_NAME installed"
|
|
147
|
+
|
|
148
|
+
Write-Info 'Registering Skill to all AI platform global directories...'
|
|
149
|
+
Invoke-Expression "$CLI_BIN init --global --force"
|
|
150
|
+
|
|
151
|
+
# Step 3: Configure API Key
|
|
152
|
+
Write-Step 'Step 3/4: Configure API Key'
|
|
153
|
+
Write-Host ''
|
|
154
|
+
Write-Host ' Opening the API Key management page. In your browser:'
|
|
155
|
+
Write-Host ' 1. Sign up / Log in to your Siluzan account'
|
|
156
|
+
Write-Host " 2. Click 'Create API Key'"
|
|
157
|
+
Write-Host " 3. Select permissions: $PERMISSION_HINT"
|
|
158
|
+
Write-Host ' 4. Copy the generated API Key'
|
|
159
|
+
Write-Host ''
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
Start-Process $API_KEY_URL
|
|
163
|
+
Write-Info 'API Key management page opened in browser'
|
|
164
|
+
} catch {
|
|
165
|
+
Write-Warn 'Could not open browser automatically. Please visit:'
|
|
166
|
+
Write-Host " $API_KEY_URL" -ForegroundColor Cyan
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
Write-Host ''
|
|
170
|
+
$apiKey = Read-Input ' Paste API Key (press Enter to skip): '
|
|
171
|
+
|
|
172
|
+
if (-not [string]::IsNullOrWhiteSpace($apiKey)) {
|
|
173
|
+
Invoke-Expression "$CLI_BIN login --api-key $apiKey"
|
|
174
|
+
Write-Info 'API Key saved to ~/.siluzan/config.json'
|
|
175
|
+
} else {
|
|
176
|
+
Write-Host ''
|
|
177
|
+
Write-Warn 'API Key configuration skipped. You can set it later:'
|
|
178
|
+
Write-Host " Option 1: $CLI_BIN login --api-key YOUR_API_KEY"
|
|
179
|
+
Write-Host ' Option 2: $env:SILUZAN_API_KEY = ''YOUR_API_KEY'''
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
# Step 4: Done
|
|
183
|
+
Write-Step 'Step 4/4: Complete'
|
|
184
|
+
Write-Host ''
|
|
185
|
+
Write-Host " $SKILL_LABEL installed successfully!" -ForegroundColor Green
|
|
186
|
+
Write-Host ''
|
|
187
|
+
Write-Host ' Skill registered to these global directories (all AI assistants):'
|
|
188
|
+
Write-Host ' ~/.cursor/skills/ ~/.claude/skills/ ~/.agents/skills/' -ForegroundColor DarkGray
|
|
189
|
+
Write-Host ' ~/.gemini/skills/ ~/.codex/skills/ ~/.kilo/skills/' -ForegroundColor DarkGray
|
|
190
|
+
Write-Host ' ~/.codeium/windsurf/skills/ ~/.config/opencode/skills/' -ForegroundColor DarkGray
|
|
191
|
+
Write-Host ' ~/.openclaw/skills/ ~/.workbuddy/skills/' -ForegroundColor DarkGray
|
|
192
|
+
Write-Host ''
|
|
193
|
+
Write-Host " Update CLI & Skill files: $CLI_BIN update"
|
|
194
|
+
Write-Host ''
|
|
195
|
+
Write-Info "Need help? Visit $WEB_BASE"
|
|
196
|
+
Write-Host ''
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
Main
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# siluzan-tso-cli - One-click install script
|
|
4
|
+
# Supported: macOS, Linux, Windows (WSL)
|
|
5
|
+
# =============================================================================
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
# -- Package info (injected at build time) ------------------------------------
|
|
10
|
+
readonly PKG_NAME="siluzan-tso-cli"
|
|
11
|
+
readonly CLI_BIN="siluzan-tso"
|
|
12
|
+
readonly SKILL_LABEL="Siluzan TSO"
|
|
13
|
+
readonly INSTALL_CMD="npm install -g siluzan-tso-cli@beta"
|
|
14
|
+
readonly PERMISSION_HINT="Assets + TSO (Ad Management)"
|
|
15
|
+
readonly WEB_BASE="https://www-ci.siluzan.com"
|
|
16
|
+
readonly API_KEY_URL="${WEB_BASE}/v3/foreign_trade/settings/apiKeyManagement"
|
|
17
|
+
|
|
18
|
+
# -- Constants ----------------------------------------------------------------
|
|
19
|
+
readonly NODE_MAJOR_MIN=18
|
|
20
|
+
readonly NPM_MIRROR="https://registry.npmmirror.com"
|
|
21
|
+
|
|
22
|
+
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
|
|
23
|
+
CYAN='\033[0;36m'; BOLD='\033[1m'; DIM='\033[2m'; NC='\033[0m'
|
|
24
|
+
|
|
25
|
+
info() { printf "${GREEN}[OK]${NC} %s\n" "$1"; }
|
|
26
|
+
warn() { printf "${YELLOW}[!]${NC} %s\n" "$1"; }
|
|
27
|
+
error() { printf "${RED}[X]${NC} %s\n" "$1" >&2; }
|
|
28
|
+
step() { printf "\n${BOLD}-- %s --${NC}\n" "$1"; }
|
|
29
|
+
|
|
30
|
+
# -- Detect OS ----------------------------------------------------------------
|
|
31
|
+
detect_os() {
|
|
32
|
+
local uname_out
|
|
33
|
+
uname_out=$(uname -s 2>/dev/null || echo "Unknown")
|
|
34
|
+
case "$uname_out" in
|
|
35
|
+
Darwin*) echo "macos" ;;
|
|
36
|
+
Linux*) echo "linux" ;;
|
|
37
|
+
MINGW*|MSYS*|CYGWIN*) echo "gitbash" ;;
|
|
38
|
+
*) echo "unknown" ;;
|
|
39
|
+
esac
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# -- Open URL in browser ------------------------------------------------------
|
|
43
|
+
open_url() {
|
|
44
|
+
local url="$1" os_type
|
|
45
|
+
os_type=$(detect_os)
|
|
46
|
+
case "$os_type" in
|
|
47
|
+
macos) open "$url" 2>/dev/null && return 0 ;;
|
|
48
|
+
linux) xdg-open "$url" 2>/dev/null && return 0 ;;
|
|
49
|
+
gitbash) start "$url" 2>/dev/null && return 0 ;;
|
|
50
|
+
esac
|
|
51
|
+
return 1
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# -- Node.js ------------------------------------------------------------------
|
|
55
|
+
node_version_ok() {
|
|
56
|
+
command -v node >/dev/null 2>&1 || return 1
|
|
57
|
+
local major
|
|
58
|
+
major=$(node -v | tr -d 'v' | cut -d. -f1)
|
|
59
|
+
[ "$major" -ge "$NODE_MAJOR_MIN" ]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
install_node() {
|
|
63
|
+
local os_type
|
|
64
|
+
os_type=$(detect_os)
|
|
65
|
+
case "$os_type" in
|
|
66
|
+
macos)
|
|
67
|
+
if command -v brew >/dev/null 2>&1; then
|
|
68
|
+
info "Installing Node.js LTS via Homebrew..."
|
|
69
|
+
brew install node@22
|
|
70
|
+
brew link --overwrite node@22 2>/dev/null || true
|
|
71
|
+
else
|
|
72
|
+
info "Installing Node.js LTS via install-node.vercel.app..."
|
|
73
|
+
curl -fsSL https://install-node.vercel.app/lts | bash -s -- --yes
|
|
74
|
+
fi
|
|
75
|
+
;;
|
|
76
|
+
linux)
|
|
77
|
+
if command -v apt-get >/dev/null 2>&1; then
|
|
78
|
+
info "Installing Node.js 22.x via NodeSource (apt)..."
|
|
79
|
+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
80
|
+
sudo apt-get install -y nodejs
|
|
81
|
+
elif command -v yum >/dev/null 2>&1; then
|
|
82
|
+
info "Installing Node.js 22.x via NodeSource (yum)..."
|
|
83
|
+
curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo -E bash -
|
|
84
|
+
sudo yum install -y nodejs
|
|
85
|
+
else
|
|
86
|
+
info "Installing Node.js LTS via install-node.vercel.app..."
|
|
87
|
+
curl -fsSL https://install-node.vercel.app/lts | bash -s -- --yes
|
|
88
|
+
fi
|
|
89
|
+
;;
|
|
90
|
+
gitbash)
|
|
91
|
+
error "Cannot auto-install Node.js in Git Bash. Please use the PowerShell script or install manually."
|
|
92
|
+
echo " https://nodejs.org/en/download/"
|
|
93
|
+
exit 1
|
|
94
|
+
;;
|
|
95
|
+
*)
|
|
96
|
+
error "Unsupported OS. Please install Node.js >= ${NODE_MAJOR_MIN} manually:"
|
|
97
|
+
echo " https://nodejs.org/en/download/"
|
|
98
|
+
exit 1
|
|
99
|
+
;;
|
|
100
|
+
esac
|
|
101
|
+
|
|
102
|
+
export PATH="$HOME/.local/bin:$HOME/.nodejs/bin:/usr/local/bin:$PATH"
|
|
103
|
+
hash -r 2>/dev/null || true
|
|
104
|
+
|
|
105
|
+
if ! node_version_ok; then
|
|
106
|
+
error "Node.js installation failed. Please install manually:"
|
|
107
|
+
echo " https://nodejs.org/en/download/"
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# -- Main ---------------------------------------------------------------------
|
|
113
|
+
main() {
|
|
114
|
+
echo ""
|
|
115
|
+
echo -e "${BOLD}+---------------------------------------------+${NC}"
|
|
116
|
+
echo -e "${BOLD}| ${SKILL_LABEL} -- Install |${NC}"
|
|
117
|
+
echo -e "${BOLD}+---------------------------------------------+${NC}"
|
|
118
|
+
echo ""
|
|
119
|
+
|
|
120
|
+
# Step 1: Environment check
|
|
121
|
+
step "Step 1/4: Environment check"
|
|
122
|
+
|
|
123
|
+
if node_version_ok; then
|
|
124
|
+
info "Node.js $(node -v) found"
|
|
125
|
+
else
|
|
126
|
+
if command -v node >/dev/null 2>&1; then
|
|
127
|
+
warn "Node.js $(node -v) is too old (need >= ${NODE_MAJOR_MIN}), upgrading..."
|
|
128
|
+
else
|
|
129
|
+
warn "Node.js not found, installing..."
|
|
130
|
+
fi
|
|
131
|
+
install_node
|
|
132
|
+
info "Node.js $(node -v) installed"
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
if command -v pnpm >/dev/null 2>&1; then
|
|
136
|
+
PKG_MANAGER="pnpm"
|
|
137
|
+
elif command -v npm >/dev/null 2>&1; then
|
|
138
|
+
PKG_MANAGER="npm"
|
|
139
|
+
else
|
|
140
|
+
error "npm not found (Node.js installation may be incomplete)"
|
|
141
|
+
exit 1
|
|
142
|
+
fi
|
|
143
|
+
info "$PKG_MANAGER ready"
|
|
144
|
+
|
|
145
|
+
local current_registry
|
|
146
|
+
current_registry=$(npm config get registry 2>/dev/null || echo "")
|
|
147
|
+
if [ "$current_registry" != "$NPM_MIRROR" ] && [ "$current_registry" != "${NPM_MIRROR}/" ]; then
|
|
148
|
+
info "Switching npm registry to China mirror for faster downloads..."
|
|
149
|
+
npm config set registry "$NPM_MIRROR"
|
|
150
|
+
info "npm registry set to $NPM_MIRROR"
|
|
151
|
+
else
|
|
152
|
+
info "npm registry already set to China mirror"
|
|
153
|
+
fi
|
|
154
|
+
|
|
155
|
+
# Step 2: Install CLI
|
|
156
|
+
step "Step 2/4: Install ${PKG_NAME}"
|
|
157
|
+
|
|
158
|
+
info "Running: ${INSTALL_CMD}"
|
|
159
|
+
$PKG_MANAGER install -g ${PKG_NAME}$(echo "${INSTALL_CMD}" | grep -o '@[^ ]*' || true)
|
|
160
|
+
info "${PKG_NAME} installed"
|
|
161
|
+
|
|
162
|
+
info "Registering Skill to all AI platform global directories..."
|
|
163
|
+
${CLI_BIN} init --global --force
|
|
164
|
+
|
|
165
|
+
# Step 3: Configure API Key
|
|
166
|
+
step "Step 3/4: Configure API Key"
|
|
167
|
+
echo ""
|
|
168
|
+
echo " Opening the API Key management page. In your browser:"
|
|
169
|
+
echo " 1. Sign up / Log in to your Siluzan account"
|
|
170
|
+
echo " 2. Click 'Create API Key'"
|
|
171
|
+
echo " 3. Select permissions: ${PERMISSION_HINT}"
|
|
172
|
+
echo " 4. Copy the generated API Key"
|
|
173
|
+
echo ""
|
|
174
|
+
|
|
175
|
+
if ! open_url "$API_KEY_URL"; then
|
|
176
|
+
warn "Could not open browser automatically. Please visit:"
|
|
177
|
+
echo -e " ${CYAN}${API_KEY_URL}${NC}"
|
|
178
|
+
else
|
|
179
|
+
info "API Key management page opened in browser"
|
|
180
|
+
fi
|
|
181
|
+
|
|
182
|
+
echo ""
|
|
183
|
+
printf " Paste API Key (press Enter to skip): "
|
|
184
|
+
local api_key=""
|
|
185
|
+
read -r api_key < /dev/tty 2>/dev/null || read -r api_key
|
|
186
|
+
|
|
187
|
+
if [ -n "$api_key" ]; then
|
|
188
|
+
${CLI_BIN} login --api-key "$api_key"
|
|
189
|
+
info "API Key saved to ~/.siluzan/config.json"
|
|
190
|
+
else
|
|
191
|
+
echo ""
|
|
192
|
+
warn "API Key configuration skipped. You can set it later:"
|
|
193
|
+
echo " Option 1: ${CLI_BIN} login --api-key YOUR_API_KEY"
|
|
194
|
+
echo " Option 2: export SILUZAN_API_KEY=YOUR_API_KEY"
|
|
195
|
+
fi
|
|
196
|
+
|
|
197
|
+
# Step 4: Done
|
|
198
|
+
step "Step 4/4: Complete"
|
|
199
|
+
echo ""
|
|
200
|
+
echo -e " ${GREEN}${SKILL_LABEL} installed successfully!${NC}"
|
|
201
|
+
echo ""
|
|
202
|
+
echo " Skill registered to these global directories (all AI assistants):"
|
|
203
|
+
echo -e " ${DIM}~/.cursor/skills/ ~/.claude/skills/ ~/.agents/skills/"
|
|
204
|
+
echo -e " ~/.gemini/skills/ ~/.codex/skills/ ~/.kilo/skills/"
|
|
205
|
+
echo -e " ~/.codeium/windsurf/skills/ ~/.config/opencode/skills/"
|
|
206
|
+
echo -e " ~/.openclaw/skills/ ~/.workbuddy/skills/${NC}"
|
|
207
|
+
echo ""
|
|
208
|
+
echo " Update CLI & Skill files: ${CLI_BIN} update"
|
|
209
|
+
echo ""
|
|
210
|
+
info "Need help? Visit ${WEB_BASE}"
|
|
211
|
+
echo ""
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
main "$@"
|