@simonyea/holysheep-cli 1.7.79 → 1.7.81
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/package.json +1 -1
- package/src/utils/shell.js +6 -0
- package/src/webui/server.js +27 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.81",
|
|
4
4
|
"description": "Claude Code/Cursor/Cline API relay for China — ¥1=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openai-china",
|
package/src/utils/shell.js
CHANGED
|
@@ -227,6 +227,12 @@ function removeEnvFromShell(extraKeys = []) {
|
|
|
227
227
|
'HOLYSHEEP_API_KEY',
|
|
228
228
|
...extraKeys,
|
|
229
229
|
]
|
|
230
|
+
|
|
231
|
+
// Windows:通过 PowerShell 删除用户级注册表环境变量
|
|
232
|
+
if (process.platform === 'win32') {
|
|
233
|
+
return removeWindowsUserEnvVars(HS_KEYS)
|
|
234
|
+
}
|
|
235
|
+
|
|
230
236
|
const files = getShellRcFiles()
|
|
231
237
|
const cleaned = []
|
|
232
238
|
for (const file of files) {
|
package/src/webui/server.js
CHANGED
|
@@ -55,8 +55,12 @@ async function validateApiKey(apiKey) {
|
|
|
55
55
|
return res.status === 200
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const { exec } = require('child_process')
|
|
59
|
+
|
|
60
|
+
function getVersionAsync(tool) {
|
|
61
|
+
if (typeof tool.getVersion === 'function') {
|
|
62
|
+
return Promise.resolve(tool.getVersion())
|
|
63
|
+
}
|
|
60
64
|
const cmds = {
|
|
61
65
|
'claude-code': 'claude --version',
|
|
62
66
|
'codex': 'codex --version',
|
|
@@ -67,10 +71,13 @@ function getVersion(tool) {
|
|
|
67
71
|
'aider': 'aider --version',
|
|
68
72
|
}
|
|
69
73
|
const cmd = cmds[tool.id]
|
|
70
|
-
if (!cmd) return null
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
if (!cmd) return Promise.resolve(null)
|
|
75
|
+
return new Promise(resolve => {
|
|
76
|
+
exec(cmd, { timeout: 5000 }, (err, stdout) => {
|
|
77
|
+
if (err) return resolve(null)
|
|
78
|
+
resolve(stdout.trim().split('\n')[0].slice(0, 30) || null)
|
|
79
|
+
})
|
|
80
|
+
})
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
function parseBody(req) {
|
|
@@ -141,17 +148,16 @@ let _latestVersion = null
|
|
|
141
148
|
let _lastCheckTime = 0
|
|
142
149
|
const UPDATE_CHECK_INTERVAL = 5 * 60 * 1000
|
|
143
150
|
|
|
144
|
-
|
|
151
|
+
// Returns cached value immediately; fetches in background when cache is stale.
|
|
152
|
+
function checkLatestVersion() {
|
|
145
153
|
const now = Date.now()
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
} catch {}
|
|
154
|
+
if (now - _lastCheckTime >= UPDATE_CHECK_INTERVAL) {
|
|
155
|
+
_lastCheckTime = now // prevent concurrent fetches
|
|
156
|
+
fetchWithRetry('https://registry.npmjs.org/@simonyea/holysheep-cli/latest', {}, 2)
|
|
157
|
+
.then(r => r.ok ? r.json() : null)
|
|
158
|
+
.then(data => { if (data?.version) _latestVersion = data.version })
|
|
159
|
+
.catch(() => {})
|
|
160
|
+
}
|
|
155
161
|
return _latestVersion
|
|
156
162
|
}
|
|
157
163
|
|
|
@@ -160,10 +166,10 @@ checkLatestVersion()
|
|
|
160
166
|
|
|
161
167
|
// ── API Handlers ─────────────────────────────────────────────────────────────
|
|
162
168
|
|
|
163
|
-
|
|
169
|
+
function handleStatus(_req, res) {
|
|
164
170
|
const apiKey = getApiKey()
|
|
165
171
|
const config = loadConfig()
|
|
166
|
-
const latest =
|
|
172
|
+
const latest = checkLatestVersion()
|
|
167
173
|
json(res, {
|
|
168
174
|
loggedIn: !!apiKey,
|
|
169
175
|
apiKey: apiKey ? maskKey(apiKey) : null,
|
|
@@ -280,21 +286,21 @@ async function handleDoctor(_req, res) {
|
|
|
280
286
|
}
|
|
281
287
|
|
|
282
288
|
async function handleTools(_req, res) {
|
|
283
|
-
const tools = TOOLS.map(t => {
|
|
289
|
+
const tools = await Promise.all(TOOLS.map(async t => {
|
|
284
290
|
const installed = t.checkInstalled()
|
|
285
291
|
return {
|
|
286
292
|
id: t.id,
|
|
287
293
|
name: t.name,
|
|
288
294
|
installed,
|
|
289
295
|
configured: installed ? (t.isConfigured?.() || false) : false,
|
|
290
|
-
version: installed ?
|
|
296
|
+
version: installed ? await getVersionAsync(t) : null,
|
|
291
297
|
installCmd: t.installCmd,
|
|
292
298
|
hint: t.hint || null,
|
|
293
299
|
launchCmd: t.launchCmd || null,
|
|
294
300
|
canAutoInstall: !!AUTO_INSTALL[t.id],
|
|
295
301
|
canUpgrade: !!UPGRADABLE_TOOLS.find(u => u.id === t.id),
|
|
296
302
|
}
|
|
297
|
-
})
|
|
303
|
+
}))
|
|
298
304
|
json(res, tools)
|
|
299
305
|
}
|
|
300
306
|
|