@simonyea/holysheep-cli 1.7.89 → 1.7.91

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonyea/holysheep-cli",
3
- "version": "1.7.89",
3
+ "version": "1.7.91",
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",
@@ -1,103 +1,42 @@
1
1
  /**
2
2
  * Antigravity 适配器 (Google Antigravity IDE)
3
3
  *
4
- * CLI 命令:agy(macOS/Linux),Windows 为桌面应用无 CLI
5
- * 配置文件:~/.gemini/settings.json(与 Gemini CLI 共享,只 merge 不覆盖)
6
- * 通过 apiEndpoint + apiKeyHeader 字段配置 HolySheep 代理
4
+ * ⚠️ 重要:Antigravity 不支持自定义 API 代理
5
+ * 它使用 Google OAuth + 专有后端 (cloudcode-pa.googleapis.com),和 Gemini CLI 一样。
6
+ *
7
+ * HolySheep 暂不支持 Antigravity 中继。
8
+ * 建议用户使用 Claude Code / Codex / OpenCode / Aider 等支持中继的工具。
7
9
  */
8
10
  'use strict'
9
11
 
10
- const fs = require('fs')
11
- const path = require('path')
12
- const os = require('os')
13
12
  const { commandExists } = require('../utils/which')
14
13
 
15
- const GEMINI_DIR = path.join(os.homedir(), '.gemini')
16
- const SETTINGS_FILE = path.join(GEMINI_DIR, 'settings.json')
17
-
18
- function readSettings() {
19
- try {
20
- if (fs.existsSync(SETTINGS_FILE)) {
21
- return JSON.parse(fs.readFileSync(SETTINGS_FILE, 'utf8'))
22
- }
23
- } catch {}
24
- return {}
25
- }
26
-
27
- function writeSettings(data) {
28
- if (!fs.existsSync(GEMINI_DIR)) fs.mkdirSync(GEMINI_DIR, { recursive: true })
29
- fs.writeFileSync(SETTINGS_FILE, JSON.stringify(data, null, 2), 'utf8')
30
- }
31
-
32
- const INSTALL_CMD = process.platform === 'win32'
33
- ? 'winget install Google.Antigravity'
34
- : process.platform === 'darwin'
35
- ? 'brew install --cask antigravity'
36
- : 'flatpak install flathub com.google.Antigravity'
37
-
38
- // Windows:通过注册表检测已安装的桌面应用(winget/MSI 安装均会注册)
39
- function isWindowsAppInstalled() {
40
- const { execSync } = require('child_process')
41
- for (const hive of ['HKLM', 'HKCU']) {
42
- try {
43
- const out = execSync(
44
- `reg query "${hive}\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall" /s /f "Antigravity" /d`,
45
- { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 3000 }
46
- )
47
- if (out.includes('Antigravity')) return true
48
- } catch {}
49
- }
50
- return false
51
- }
52
-
53
14
  module.exports = {
54
15
  name: 'Antigravity',
55
16
  id: 'antigravity',
56
17
 
57
- // 桌面应用:即使检测不到也允许配置(只写 settings.json)
58
- configOnly: true,
59
-
60
18
  checkInstalled() {
61
- // CLI in PATH
62
- if (commandExists('agy')) return true
63
- // Windows: 注册表检测桌面应用
64
- if (process.platform === 'win32') {
65
- if (isWindowsAppInstalled()) return true
66
- // 兜底:.gemini 目录存在说明 Antigravity/Gemini 曾运行过
67
- if (fs.existsSync(GEMINI_DIR)) return true
68
- }
69
- // macOS: .app 检测
70
- if (process.platform === 'darwin') return fs.existsSync('/Applications/Antigravity.app')
71
- return false
19
+ return commandExists('agy')
72
20
  },
73
21
 
74
22
  isConfigured() {
75
- const s = readSettings()
76
- return !!(s.apiKey?.startsWith('cr_') && s.apiEndpoint?.includes('holysheep.ai'))
23
+ return false
77
24
  },
78
25
 
79
- configure(apiKey, _baseUrlAnthropic, baseUrlOpenAI) {
80
- const settings = readSettings()
81
- settings.selectedAuthType = 'api-key'
82
- settings.apiKey = apiKey
83
- settings.apiEndpoint = baseUrlOpenAI // https://api.holysheep.ai/v1
84
- settings.apiKeyHeader = 'authorization'
85
- writeSettings(settings)
86
- return { file: SETTINGS_FILE, hot: true }
26
+ configure() {
27
+ return {
28
+ manual: true,
29
+ steps: [
30
+ 'Antigravity 使用 Google OAuth 认证 + Google 专有后端,无法配置自定义 API 代理',
31
+ '建议使用 Claude Code / Codex / OpenCode / Aider 等支持自定义 API 的工具',
32
+ ],
33
+ }
87
34
  },
88
35
 
89
- reset() {
90
- const s = readSettings()
91
- delete s.apiKey
92
- delete s.apiEndpoint
93
- delete s.apiKeyHeader
94
- if (s.selectedAuthType === 'api-key') delete s.selectedAuthType
95
- writeSettings(s)
96
- },
36
+ reset() {},
97
37
 
98
- getConfigPath() { return SETTINGS_FILE },
99
- launchCmd: process.platform === 'win32' ? null : 'agy',
100
- installCmd: INSTALL_CMD,
101
- hint: '配置写入 ~/.gemini/settings.json',
38
+ getConfigPath() { return null },
39
+ hint: 'Antigravity 使用 Google 专有协议,不支持 HolySheep 中继',
102
40
  docsUrl: 'https://antigravity.google',
41
+ unsupported: true,
103
42
  }
@@ -26,6 +26,7 @@ const CONFIG_DIR = path.join(os.homedir(), '.codex')
26
26
  const CONFIG_FILE = path.join(CONFIG_DIR, 'config.toml')
27
27
  // 保留 JSON 兼容性(老版本 TypeScript Codex 用)
28
28
  const CONFIG_FILE_JSON = path.join(CONFIG_DIR, 'config.json')
29
+ const AUTH_FILE = path.join(CONFIG_DIR, 'auth.json')
29
30
 
30
31
  function normalizeToml(content) {
31
32
  return String(content || '').replace(/\r\n/g, '\n')
@@ -149,6 +150,28 @@ function writeJsonConfigIfNeeded(apiKey, baseUrlOpenAI, model) {
149
150
  } catch {}
150
151
  }
151
152
 
153
+ /**
154
+ * 清除 auth.json 中的 ChatGPT OAuth 认证,避免干扰 holysheep provider
155
+ * Codex RS bug: auth_mode=chatgpt 时 OAuth token 会覆盖自定义 provider 的 api_key
156
+ */
157
+ function neutralizeAuthJson() {
158
+ try {
159
+ if (!fs.existsSync(AUTH_FILE)) return
160
+
161
+ const auth = JSON.parse(fs.readFileSync(AUTH_FILE, 'utf8'))
162
+
163
+ // 只在 chatgpt 模式时处理
164
+ if (auth.auth_mode !== 'chatgpt') return
165
+
166
+ // 切换为 api-key 模式,清除 OAuth tokens
167
+ auth.auth_mode = 'api-key'
168
+ auth.OPENAI_API_KEY = null
169
+ delete auth.tokens
170
+
171
+ fs.writeFileSync(AUTH_FILE, JSON.stringify(auth, null, 2), 'utf8')
172
+ } catch {}
173
+ }
174
+
152
175
  module.exports = {
153
176
  name: 'Codex CLI',
154
177
  id: 'codex',
@@ -167,6 +190,12 @@ module.exports = {
167
190
  // 同时写 JSON(兼容旧版 TypeScript Codex)
168
191
  writeJsonConfigIfNeeded(apiKey, baseUrlOpenAI, model)
169
192
 
193
+ // 清除 auth.json 中的 ChatGPT OAuth 认证
194
+ // Codex RS 在 auth_mode=chatgpt 时会用 OAuth JWT token 做 Authorization header,
195
+ // 即使 config.toml 里设置了自定义 model_provider 的 api_key 也会被覆盖,
196
+ // 导致 holysheep 收到非 cr_ 前缀的 token 返回 401。
197
+ neutralizeAuthJson()
198
+
170
199
  return {
171
200
  file: CONFIG_FILE,
172
201
  hot: false,
@@ -7,5 +7,4 @@ module.exports = [
7
7
  require('./droid'),
8
8
  require('./opencode'),
9
9
  require('./openclaw'),
10
- require('./antigravity'),
11
10
  ]
@@ -122,13 +122,6 @@ const AUTO_INSTALL = {
122
122
  'opencode': { cmd: 'npm install -g opencode-ai' },
123
123
  'openclaw': { cmd: 'npm install -g openclaw@latest --ignore-scripts' },
124
124
  'aider': { cmd: 'pip install aider-chat' },
125
- 'antigravity': {
126
- cmd: process.platform === 'win32'
127
- ? 'winget install Google.Antigravity'
128
- : process.platform === 'darwin'
129
- ? 'brew install --cask antigravity'
130
- : 'flatpak install flathub com.google.Antigravity',
131
- },
132
125
  }
133
126
 
134
127
  // ── UPGRADABLE_TOOLS (from upgrade.js) ───────────────────────────────────────
@@ -147,15 +140,6 @@ const UPGRADABLE_TOOLS = [
147
140
  { name: 'OpenCode', id: 'opencode', command: 'opencode', versionCmd: 'opencode --version', npmPkg: 'opencode-ai', installCmd: 'npm install -g opencode-ai@latest' },
148
141
  { name: 'OpenClaw', id: 'openclaw', command: 'openclaw', versionCmd: 'openclaw --version', npmPkg: 'openclaw', installCmd: 'npm install -g openclaw@latest --ignore-scripts' },
149
142
  { name: 'Gemini CLI', id: 'gemini-cli', command: 'gemini', versionCmd: 'gemini --version', npmPkg: '@google/gemini-cli', installCmd: 'npm install -g @google/gemini-cli@latest' },
150
- {
151
- name: 'Antigravity', id: 'antigravity', command: 'agy',
152
- versionCmd: 'agy --version', npmPkg: null,
153
- installCmd: process.platform === 'win32'
154
- ? 'winget install Google.Antigravity'
155
- : process.platform === 'darwin'
156
- ? 'brew install --cask antigravity'
157
- : 'flatpak install flathub com.google.Antigravity',
158
- },
159
143
  ]
160
144
 
161
145
  // ── Update check (cached, refreshes every 30min) ────────────────────────────
@@ -304,12 +288,11 @@ async function handleDoctor(_req, res) {
304
288
  async function handleTools(_req, res) {
305
289
  const tools = await Promise.all(TOOLS.map(async t => {
306
290
  const installed = t.checkInstalled()
307
- const canConfigure = installed || !!t.configOnly
308
291
  return {
309
292
  id: t.id,
310
293
  name: t.name,
311
- installed: canConfigure,
312
- configured: canConfigure ? (t.isConfigured?.() || false) : false,
294
+ installed,
295
+ configured: installed ? (t.isConfigured?.() || false) : false,
313
296
  version: installed ? await getVersionAsync(t) : null,
314
297
  installCmd: t.installCmd,
315
298
  hint: t.hint || null,
@@ -537,7 +520,7 @@ async function handleToolConfigure(req, res) {
537
520
 
538
521
  sseStart(res)
539
522
 
540
- if (!tool.checkInstalled() && !tool.configOnly) {
523
+ if (!tool.checkInstalled()) {
541
524
  sseEmit(res, { type: 'error', message: `${tool.name} 未安装` })
542
525
  sseEmit(res, { type: 'done', success: false })
543
526
  return res.end()