skillfree 0.1.21 → 0.1.22
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/bin/skillfree.js +7 -0
- package/install.sh +41 -4
- package/package.json +1 -1
- package/scripts/commands/auth.js +15 -1
package/bin/skillfree.js
CHANGED
|
@@ -18,6 +18,13 @@ auth
|
|
|
18
18
|
const { authLogin } = require('../scripts/commands/auth')
|
|
19
19
|
await authLogin()
|
|
20
20
|
})
|
|
21
|
+
auth
|
|
22
|
+
.command('save <apiKey>')
|
|
23
|
+
.description('直接保存 API Key(供安装脚本调用)')
|
|
24
|
+
.action(async (apiKey) => {
|
|
25
|
+
const { authSave } = require('../scripts/commands/auth')
|
|
26
|
+
await authSave(apiKey)
|
|
27
|
+
})
|
|
21
28
|
auth
|
|
22
29
|
.command('status')
|
|
23
30
|
.description('查看当前登录状态和积分')
|
package/install.sh
CHANGED
|
@@ -80,7 +80,7 @@ fi
|
|
|
80
80
|
echo ""
|
|
81
81
|
success "SkillFree CLI 安装完成"
|
|
82
82
|
|
|
83
|
-
# 刷新 PATH
|
|
83
|
+
# 刷新 PATH
|
|
84
84
|
hash -r 2>/dev/null || true
|
|
85
85
|
export PATH="$(npm root -g)/../bin:$PATH"
|
|
86
86
|
|
|
@@ -91,14 +91,51 @@ if ! command -v skillfree &>/dev/null; then
|
|
|
91
91
|
exit 0
|
|
92
92
|
fi
|
|
93
93
|
|
|
94
|
-
# ── Step 3:
|
|
94
|
+
# ── Step 3: 登录(从 /dev/tty 读取,兼容 curl | bash)────────────────────────
|
|
95
95
|
step "[ 3 / 3 ] 登录账号"
|
|
96
96
|
echo ""
|
|
97
97
|
echo -e " 还没有账号?${CYAN}https://skillfree.tech/app${NC} 免费注册"
|
|
98
|
-
echo -e " 注册后进入控制台 → API Keys → 创建一个 Key,粘贴到下方"
|
|
98
|
+
echo -e " 注册后进入控制台 → ${BOLD}API Keys${NC} → 创建一个 Key,粘贴到下方"
|
|
99
99
|
echo ""
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
API_KEY=""
|
|
102
|
+
while true; do
|
|
103
|
+
# 强制从 /dev/tty 读取,避免 curl | bash 时 stdin 被占用
|
|
104
|
+
printf " 请粘贴 API Key (sk-sf-...),输入 q 跳过: "
|
|
105
|
+
read -r API_KEY </dev/tty
|
|
106
|
+
|
|
107
|
+
if [ "$API_KEY" = "q" ] || [ -z "$API_KEY" ]; then
|
|
108
|
+
echo ""
|
|
109
|
+
warn "已跳过登录,稍后可运行 ${CYAN}skillfree auth login${NC} 完成配置"
|
|
110
|
+
API_KEY=""
|
|
111
|
+
break
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
if [[ "$API_KEY" != sk-sf-* ]]; then
|
|
115
|
+
echo -e " ${RED}✗${NC} 格式不对,Key 应以 sk-sf- 开头,请重试\n"
|
|
116
|
+
continue
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
# 验证 Key
|
|
120
|
+
printf " 验证中..."
|
|
121
|
+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
122
|
+
-H "Authorization: Bearer $API_KEY" \
|
|
123
|
+
"https://skillfree.tech/v1/balance")
|
|
124
|
+
|
|
125
|
+
if [ "$HTTP_CODE" = "200" ]; then
|
|
126
|
+
echo -e " ${GREEN}✓${NC}"
|
|
127
|
+
break
|
|
128
|
+
else
|
|
129
|
+
echo -e " ${RED}✗${NC} (HTTP $HTTP_CODE)"
|
|
130
|
+
echo -e " ${RED}✗${NC} Key 无效,请检查后重试\n"
|
|
131
|
+
API_KEY=""
|
|
132
|
+
fi
|
|
133
|
+
done
|
|
134
|
+
|
|
135
|
+
# 有效 Key → 交给 CLI 写入配置
|
|
136
|
+
if [ -n "$API_KEY" ]; then
|
|
137
|
+
SKILLFREE_API_KEY="$API_KEY" skillfree auth save "$API_KEY"
|
|
138
|
+
fi
|
|
102
139
|
|
|
103
140
|
# ── 完成 ──────────────────────────────────────────────────────────────────────
|
|
104
141
|
echo ""
|
package/package.json
CHANGED
package/scripts/commands/auth.js
CHANGED
|
@@ -112,6 +112,19 @@ async function authLogin() {
|
|
|
112
112
|
rl.close()
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
async function authSave(apiKey) {
|
|
116
|
+
if (!apiKey || !apiKey.startsWith('sk-sf-')) {
|
|
117
|
+
console.error('❌ Key 格式不正确')
|
|
118
|
+
process.exit(1)
|
|
119
|
+
}
|
|
120
|
+
saveConfig({ apiKey })
|
|
121
|
+
injectToOpenclaw(apiKey)
|
|
122
|
+
console.log(`\n🎉 登录成功!`)
|
|
123
|
+
console.log(`\n快速开始:`)
|
|
124
|
+
console.log(` skillfree pilot --type chat --prompt "你好"`)
|
|
125
|
+
console.log(` skillfree models # 查看所有可用模型`)
|
|
126
|
+
}
|
|
127
|
+
|
|
115
128
|
async function authStatus() {
|
|
116
129
|
const { getApiKey, BASE_URL } = require('../lib/client')
|
|
117
130
|
const key = getApiKey()
|
|
@@ -132,4 +145,5 @@ async function authStatus() {
|
|
|
132
145
|
console.log(` Key:${key.slice(0, 10)}****${key.slice(-4)}`)
|
|
133
146
|
}
|
|
134
147
|
|
|
135
|
-
module.exports = { authLogin, authStatus }
|
|
148
|
+
module.exports = { authLogin, authSave, authStatus }
|
|
149
|
+
|