fogact 1.1.4 → 1.1.5
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 +40 -196
- package/README.zh-CN.md +40 -196
- package/install.sh +5 -14
- package/lib/index.js +25 -17
- package/lib/services/activation-orchestrator.js +26 -15
- package/lib/services/cliproxy-api.js +1 -1
- package/lib/services/newapi.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,222 +2,81 @@
|
|
|
2
2
|
|
|
3
3
|
[简体中文](./README.zh-CN.md) | English
|
|
4
4
|
|
|
5
|
-
FogAct is a
|
|
5
|
+
FogAct is a simple activation helper for Claude Code and Codex. It is designed to be used like `npx yunyi-activator`: run one command, choose from the menu, paste your activation code or API key, and let the tool write the local config automatically.
|
|
6
6
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
Run the terminal activation menu directly with npx:
|
|
7
|
+
## Start
|
|
10
8
|
|
|
11
9
|
```bash
|
|
12
10
|
npx fogact
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
For a clean VPS without Node.js/npm, copy this command. It can install Node.js automatically when missing, install the latest `fogact` npm package, and prepare the CLI without requiring git or npx.
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Install and activate Codex with an activation code:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh -s -- \
|
|
27
|
-
--service codex \
|
|
28
|
-
--code YOUR_ACTIVATION_CODE \
|
|
29
|
-
--cliproxy-api-base https://your-activator.example.com
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Install and activate Claude Code with an activation code:
|
|
13
|
+
That is the user-facing command. Running it opens the interactive menu:
|
|
33
14
|
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Install and activate directly with a NewAPI key:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh -s -- \
|
|
45
|
-
--service codex \
|
|
46
|
-
--base-url https://newapi.example.com \
|
|
47
|
-
--api-key sk-your-upstream-key
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Start the local Web UI after install:
|
|
15
|
+
```text
|
|
16
|
+
╭─────────────────────────────────────╮
|
|
17
|
+
│ FogAct Activator │
|
|
18
|
+
│ Claude Code / Codex Config Tool │
|
|
19
|
+
╰─────────────────────────────────────╯
|
|
51
20
|
|
|
52
|
-
|
|
53
|
-
|
|
21
|
+
? Select an action:
|
|
22
|
+
1. Activate service
|
|
23
|
+
2. Test nodes
|
|
24
|
+
3. Restore backup
|
|
25
|
+
4. Exit
|
|
54
26
|
```
|
|
55
27
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## What It Does
|
|
28
|
+
Do not run `npm fogact`; npm treats that as an npm subcommand. Use `npx fogact`.
|
|
59
29
|
|
|
60
|
-
|
|
61
|
-
- Activates Codex CLI and Claude Code by writing their local config files.
|
|
62
|
-
- Optionally configures OpenCode, OpenClaw, VSCode Codex plugin, and Cursor Codex plugin when selected or detected.
|
|
63
|
-
- Reads activation-code capabilities so users only see supported services/platforms.
|
|
64
|
-
- Verifies direct NewAPI keys through `/v1/models` before writing config.
|
|
65
|
-
- Backs up existing config before writing changes.
|
|
66
|
-
- Provides a local Web UI for users, admin management, activation codes, and settings.
|
|
30
|
+
## Clean VPS
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
| Target | Service | Default behavior |
|
|
71
|
-
| --- | --- | --- |
|
|
72
|
-
| Codex CLI | Codex | Creates `~/.codex/config.toml` and `~/.codex/auth.json` |
|
|
73
|
-
| Claude Code | Claude | Creates `~/.claude/settings.json` and `~/.claude.json` |
|
|
74
|
-
| OpenCode | Codex / Claude | Configures when installed or selected with `--all` / `--platforms` |
|
|
75
|
-
| OpenClaw | Codex / Claude | Configures when installed or selected with `--all` / `--platforms` |
|
|
76
|
-
| VSCode Codex plugin | Codex | Patches only when compatible plugin files are detected |
|
|
77
|
-
| Cursor Codex plugin | Codex | Patches only when compatible plugin files are detected |
|
|
78
|
-
|
|
79
|
-
## Install Options
|
|
80
|
-
|
|
81
|
-
### npx
|
|
82
|
-
|
|
83
|
-
Run the activator directly, matching the `npx yunyi-activator` style:
|
|
32
|
+
If the machine does not have Node.js/npm yet, use the bootstrap installer first:
|
|
84
33
|
|
|
85
34
|
```bash
|
|
86
|
-
|
|
35
|
+
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh
|
|
87
36
|
```
|
|
88
37
|
|
|
89
|
-
|
|
38
|
+
After installation, run:
|
|
90
39
|
|
|
91
40
|
```bash
|
|
92
|
-
npm install -g fogact
|
|
93
41
|
fogact
|
|
94
42
|
```
|
|
95
43
|
|
|
96
|
-
|
|
44
|
+
Minimum bootstrap requirement: the machine needs `curl` or `wget`. The installer can install Node.js/npm on common Linux distributions.
|
|
97
45
|
|
|
98
|
-
|
|
99
|
-
git clone https://github.com/FogMaly/fogact.git
|
|
100
|
-
cd cliproxy-activator
|
|
101
|
-
npm install
|
|
102
|
-
node bin/cli.js --help
|
|
103
|
-
```
|
|
46
|
+
## What Users Do
|
|
104
47
|
|
|
105
|
-
|
|
48
|
+
1. Run `npx fogact`.
|
|
49
|
+
2. Choose `1. Activate service`.
|
|
50
|
+
3. Select Claude Code or Codex when prompted.
|
|
51
|
+
4. Enter the activation code or API key.
|
|
52
|
+
5. Confirm the plan and restart the target tool.
|
|
106
53
|
|
|
107
|
-
|
|
54
|
+
FogAct backs up existing configuration before writing new files.
|
|
108
55
|
|
|
109
|
-
|
|
110
|
-
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh -s -- --method github
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Activation Usage
|
|
114
|
-
|
|
115
|
-
### Activation code / CDK mode
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
export CLIPROXY_API_BASE="https://your-activator.example.com"
|
|
119
|
-
fogact wizard --code YOUR_ACTIVATION_CODE --yes
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Activate a specific service:
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
fogact wizard --service codex --code YOUR_ACTIVATION_CODE --yes
|
|
126
|
-
fogact wizard --service claude --code YOUR_ACTIVATION_CODE --yes
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
Activate selected platforms only:
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
fogact wizard --service codex --platforms codex-cli,opencode --yes
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Direct NewAPI mode
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
export NEWAPI_BASE_URL="https://newapi.example.com"
|
|
139
|
-
export NEWAPI_API_KEY="sk-your-upstream-key"
|
|
140
|
-
fogact activate --service codex --yes
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Skip upstream verification for local dry-runs:
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
fogact activate --service codex --api-key sk-test --yes --skip-verify
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Legacy node-switching activation-code mode is still available:
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
fogact activate --service codex --code YOUR_ACTIVATION_CODE --legacy
|
|
153
|
-
```
|
|
56
|
+
## Supported Targets
|
|
154
57
|
|
|
155
|
-
|
|
58
|
+
| Target | Default behavior |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| Codex CLI | Writes `~/.codex/config.toml` and `~/.codex/auth.json` |
|
|
61
|
+
| Claude Code | Writes `~/.claude/settings.json` and `~/.claude.json` |
|
|
62
|
+
| OpenCode | Configures when installed or selected by the wizard |
|
|
63
|
+
| OpenClaw | Configures when installed or selected by the wizard |
|
|
64
|
+
| VSCode / Cursor Codex plugin | Patches only when compatible plugin files are detected |
|
|
156
65
|
|
|
157
|
-
|
|
66
|
+
## Advanced
|
|
158
67
|
|
|
159
|
-
|
|
160
|
-
fogact-web
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Or from this repository:
|
|
68
|
+
Most users only need `npx fogact`. Advanced operators can still use:
|
|
164
69
|
|
|
165
70
|
```bash
|
|
166
|
-
npm run web
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Default endpoints:
|
|
170
|
-
|
|
171
|
-
- User UI: `http://localhost:34020/`
|
|
172
|
-
- Admin UI: `http://localhost:34020/admin/`
|
|
173
|
-
|
|
174
|
-
Useful environment variables:
|
|
175
|
-
|
|
176
|
-
- `PORT`: override the default port `34020`
|
|
177
|
-
- `ADMIN_PASSWORD`: override the default admin password `admin123`
|
|
178
|
-
- `SERVER_TIMEZONE`: override the default timezone `Asia/Shanghai`
|
|
179
|
-
- `NEWAPI_BASE_URL`: upstream NewAPI base URL for CLI activation
|
|
180
|
-
- `NEWAPI_API_KEY`: upstream NewAPI key for CLI activation
|
|
181
|
-
- `CLIPROXY_API_BASE`: activation-code backend URL for CLI code mode
|
|
182
|
-
- `CLIPROXY_UPSTREAM_CONFIG`: custom path for upstream config JSON
|
|
183
|
-
- `FOGIDC_BACKUP_DIR`: custom backup directory for activation config backups
|
|
184
|
-
|
|
185
|
-
## Commands
|
|
186
|
-
|
|
187
|
-
```text
|
|
188
|
-
fogact
|
|
189
71
|
fogact web
|
|
190
|
-
fogact interactive
|
|
191
|
-
fogact wizard [--code <activation-code>] [--platforms <ids>]
|
|
192
|
-
fogact activate --service <claude|codex> [--api-key <key>] [--yes]
|
|
193
|
-
fogact activate --service <claude|codex> --code <activation-code> --legacy
|
|
194
|
-
fogact test
|
|
195
|
-
fogact restore --service <claude|codex>
|
|
196
|
-
fogact-web
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Activation Code Capabilities
|
|
200
|
-
|
|
201
|
-
The wizard supports capability-scoped activation codes. The code verification API can return fields such as `service`, `services`, `platforms`, `targets`, or `capabilities`; the CLI normalizes them and filters activation choices automatically.
|
|
202
|
-
|
|
203
|
-
Examples:
|
|
204
|
-
|
|
205
|
-
```json
|
|
206
|
-
{ "service": "codex" }
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
```json
|
|
210
|
-
{ "capabilities": { "services": ["claude"], "platforms": ["claude-code", "opencode"] } }
|
|
211
72
|
```
|
|
212
73
|
|
|
213
|
-
|
|
74
|
+
The Web UI defaults to `http://localhost:34020/`. You can set `PORT`, `ADMIN_PASSWORD`, `NEWAPI_BASE_URL`, `NEWAPI_API_KEY`, `CLIPROXY_API_BASE`, or `CLIPROXY_UPSTREAM_CONFIG` when needed.
|
|
214
75
|
|
|
215
|
-
##
|
|
76
|
+
## Repository
|
|
216
77
|
|
|
217
|
-
-
|
|
218
|
-
-
|
|
219
|
-
- OpenCode: `~/.config/opencode/opencode.json`
|
|
220
|
-
- OpenClaw: `~/.openclaw/openclaw.json`
|
|
78
|
+
- GitHub: https://github.com/FogMaly/fogact
|
|
79
|
+
- npm: https://www.npmjs.com/package/fogact
|
|
221
80
|
- Backups: `~/.fogact/backups/`
|
|
222
81
|
|
|
223
82
|
## Development
|
|
@@ -227,18 +86,3 @@ npm install
|
|
|
227
86
|
npm test
|
|
228
87
|
npm run web
|
|
229
88
|
```
|
|
230
|
-
|
|
231
|
-
Project layout:
|
|
232
|
-
|
|
233
|
-
- `bin/`: CLI and web server entry points
|
|
234
|
-
- `lib/`: command, service, platform and config implementation
|
|
235
|
-
- `frontend/`: static frontend assets
|
|
236
|
-
- `install.sh`: clean VPS bootstrap installer
|
|
237
|
-
- `docs/`: implementation notes and delivery documents
|
|
238
|
-
- `scripts/`: helper scripts
|
|
239
|
-
- `test/`: lightweight test scripts
|
|
240
|
-
- `data/`: local runtime data, intentionally not committed
|
|
241
|
-
|
|
242
|
-
## License
|
|
243
|
-
|
|
244
|
-
MIT. See `LICENSE`.
|
package/README.zh-CN.md
CHANGED
|
@@ -1,223 +1,82 @@
|
|
|
1
1
|
# FogAct
|
|
2
2
|
|
|
3
|
-
FogAct
|
|
3
|
+
FogAct 是一个简单的 Claude Code / Codex 激活工具。它的使用方式要和 `npx yunyi-activator` 一样:用户只运行一个命令,进入菜单,输入激活码或 API Key,然后自动写入本地配置。
|
|
4
4
|
|
|
5
5
|
[English](./README.md) | 简体中文
|
|
6
6
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
直接用 npx 拉起终端激活菜单:
|
|
7
|
+
## 开始使用
|
|
10
8
|
|
|
11
9
|
```bash
|
|
12
10
|
npx fogact
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
如果是没有 Node.js/npm 的干净 VPS,再复制下面命令即可。脚本会在缺少 Node.js 时自动安装 Node.js,然后安装最新的 `fogact` npm 包;不要求机器预装 git 或 npx。
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
使用激活码安装并激活 Codex:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh -s -- \
|
|
27
|
-
--service codex \
|
|
28
|
-
--code YOUR_ACTIVATION_CODE \
|
|
29
|
-
--cliproxy-api-base https://your-activator.example.com
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
使用激活码安装并激活 Claude Code:
|
|
13
|
+
这是给用户看的主命令。运行后会打开交互菜单:
|
|
33
14
|
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
使用 NewAPI Key 直连安装并激活:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh -s -- \
|
|
45
|
-
--service codex \
|
|
46
|
-
--base-url https://newapi.example.com \
|
|
47
|
-
--api-key sk-your-upstream-key
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
安装后启动本地 Web UI:
|
|
15
|
+
```text
|
|
16
|
+
╭─────────────────────────────────────╮
|
|
17
|
+
│ FogAct 激活器 │
|
|
18
|
+
│ Claude Code / Codex 配置工具 │
|
|
19
|
+
╰─────────────────────────────────────╯
|
|
51
20
|
|
|
52
|
-
|
|
53
|
-
|
|
21
|
+
? 请选择操作:
|
|
22
|
+
1. 激活服务
|
|
23
|
+
2. 测试节点
|
|
24
|
+
3. 恢复备份
|
|
25
|
+
4. 退出
|
|
54
26
|
```
|
|
55
27
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## 功能说明
|
|
28
|
+
不要运行 `npm fogact`;npm 会把它当成 npm 子命令。正确方式是 `npx fogact`。
|
|
59
29
|
|
|
60
|
-
|
|
61
|
-
- 为 Codex CLI 和 Claude Code 写入本地配置文件完成激活。
|
|
62
|
-
- 可按需配置 OpenCode、OpenClaw、VSCode Codex 插件和 Cursor Codex 插件。
|
|
63
|
-
- 会读取激活码能力范围,只展示该激活码支持的服务和平台。
|
|
64
|
-
- NewAPI Key 直连模式会先通过 `/v1/models` 验证可用性。
|
|
65
|
-
- 写入配置前会自动备份已有配置。
|
|
66
|
-
- 提供本地 Web UI,用于用户页、管理后台、激活码和上游设置管理。
|
|
30
|
+
## 干净 VPS
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
| 目标 | 服务 | 默认行为 |
|
|
71
|
-
| --- | --- | --- |
|
|
72
|
-
| Codex CLI | Codex | 创建 `~/.codex/config.toml` 和 `~/.codex/auth.json` |
|
|
73
|
-
| Claude Code | Claude | 创建 `~/.claude/settings.json` 和 `~/.claude.json` |
|
|
74
|
-
| OpenCode | Codex / Claude | 已安装或通过 `--all` / `--platforms` 选择时配置 |
|
|
75
|
-
| OpenClaw | Codex / Claude | 已安装或通过 `--all` / `--platforms` 选择时配置 |
|
|
76
|
-
| VSCode Codex 插件 | Codex | 仅在检测到兼容插件文件时修补 |
|
|
77
|
-
| Cursor Codex 插件 | Codex | 仅在检测到兼容插件文件时修补 |
|
|
78
|
-
|
|
79
|
-
## 安装方式
|
|
80
|
-
|
|
81
|
-
### npx
|
|
82
|
-
|
|
83
|
-
直接运行激活器,操作方式对齐 `npx yunyi-activator`:
|
|
32
|
+
如果机器还没有 Node.js/npm,先用 bootstrap 安装:
|
|
84
33
|
|
|
85
34
|
```bash
|
|
86
|
-
|
|
35
|
+
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh
|
|
87
36
|
```
|
|
88
37
|
|
|
89
|
-
|
|
38
|
+
安装完成后运行:
|
|
90
39
|
|
|
91
40
|
```bash
|
|
92
|
-
npm install -g fogact
|
|
93
41
|
fogact
|
|
94
42
|
```
|
|
95
43
|
|
|
96
|
-
|
|
44
|
+
最低要求:机器需要有 `curl` 或 `wget`。安装脚本会在常见 Linux 发行版上自动安装 Node.js/npm。
|
|
97
45
|
|
|
98
|
-
|
|
99
|
-
git clone https://github.com/FogMaly/fogact.git
|
|
100
|
-
cd cliproxy-activator
|
|
101
|
-
npm install
|
|
102
|
-
node bin/cli.js --help
|
|
103
|
-
```
|
|
46
|
+
## 用户操作流程
|
|
104
47
|
|
|
105
|
-
|
|
48
|
+
1. 运行 `npx fogact`。
|
|
49
|
+
2. 选择 `1. 激活服务`。
|
|
50
|
+
3. 根据提示选择 Claude Code 或 Codex。
|
|
51
|
+
4. 输入激活码或 API Key。
|
|
52
|
+
5. 确认激活计划,然后重启对应工具。
|
|
106
53
|
|
|
107
|
-
|
|
54
|
+
FogAct 写入新配置前会自动备份旧配置。
|
|
108
55
|
|
|
109
|
-
|
|
110
|
-
curl -fsSL https://raw.githubusercontent.com/FogMaly/fogact/main/install.sh | sh -s -- --method github
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## 激活用法
|
|
114
|
-
|
|
115
|
-
### 激活码 / CDK 模式
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
export CLIPROXY_API_BASE="https://your-activator.example.com"
|
|
119
|
-
fogact wizard --code YOUR_ACTIVATION_CODE --yes
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
指定服务:
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
fogact wizard --service codex --code YOUR_ACTIVATION_CODE --yes
|
|
126
|
-
fogact wizard --service claude --code YOUR_ACTIVATION_CODE --yes
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
只激活指定平台:
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
fogact wizard --service codex --platforms codex-cli,opencode --yes
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### NewAPI Key 直连模式
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
export NEWAPI_BASE_URL="https://newapi.example.com"
|
|
139
|
-
export NEWAPI_API_KEY="sk-your-upstream-key"
|
|
140
|
-
fogact activate --service codex --yes
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
本地测试时跳过上游验证:
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
fogact activate --service codex --api-key sk-test --yes --skip-verify
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
旧版节点切换激活码模式仍然保留:
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
fogact activate --service codex --code YOUR_ACTIVATION_CODE --legacy
|
|
153
|
-
```
|
|
56
|
+
## 支持目标
|
|
154
57
|
|
|
155
|
-
|
|
58
|
+
| 目标 | 默认行为 |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| Codex CLI | 写入 `~/.codex/config.toml` 和 `~/.codex/auth.json` |
|
|
61
|
+
| Claude Code | 写入 `~/.claude/settings.json` 和 `~/.claude.json` |
|
|
62
|
+
| OpenCode | 已安装或由向导选择时配置 |
|
|
63
|
+
| OpenClaw | 已安装或由向导选择时配置 |
|
|
64
|
+
| VSCode / Cursor Codex 插件 | 仅在检测到兼容插件文件时修补 |
|
|
156
65
|
|
|
157
|
-
|
|
66
|
+
## 高级入口
|
|
158
67
|
|
|
159
|
-
|
|
160
|
-
fogact-web
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
或在源码仓库中运行:
|
|
68
|
+
普通用户只需要 `npx fogact`。管理员仍可使用:
|
|
164
69
|
|
|
165
70
|
```bash
|
|
166
|
-
npm run web
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
默认地址:
|
|
170
|
-
|
|
171
|
-
- 用户页面:`http://localhost:34020/`
|
|
172
|
-
- 管理后台:`http://localhost:34020/admin/`
|
|
173
|
-
|
|
174
|
-
常用环境变量:
|
|
175
|
-
|
|
176
|
-
- `PORT`:覆盖默认端口 `34020`
|
|
177
|
-
- `ADMIN_PASSWORD`:覆盖默认管理密码 `admin123`
|
|
178
|
-
- `SERVER_TIMEZONE`:覆盖默认时区 `Asia/Shanghai`
|
|
179
|
-
- `NEWAPI_BASE_URL`:CLI 激活使用的 NewAPI 上游地址
|
|
180
|
-
- `NEWAPI_API_KEY`:CLI 激活使用的 NewAPI Key
|
|
181
|
-
- `CLIPROXY_API_BASE`:激活码模式使用的激活后台地址
|
|
182
|
-
- `CLIPROXY_UPSTREAM_CONFIG`:自定义上游配置 JSON 路径
|
|
183
|
-
- `FOGIDC_BACKUP_DIR`:自定义激活配置备份目录
|
|
184
|
-
|
|
185
|
-
## 命令列表
|
|
186
|
-
|
|
187
|
-
```text
|
|
188
|
-
fogact
|
|
189
71
|
fogact web
|
|
190
|
-
fogact interactive
|
|
191
|
-
fogact wizard [--code <activation-code>] [--platforms <ids>]
|
|
192
|
-
fogact activate --service <claude|codex> [--api-key <key>] [--yes]
|
|
193
|
-
fogact activate --service <claude|codex> --code <activation-code> --legacy
|
|
194
|
-
fogact test
|
|
195
|
-
fogact restore --service <claude|codex>
|
|
196
|
-
fogact-web
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## 激活码能力范围
|
|
200
|
-
|
|
201
|
-
向导支持按能力范围限制激活码。校验接口可返回 `service`、`services`、`platforms`、`targets` 或 `capabilities` 等字段;CLI 会自动归一化并过滤可选服务和平台。
|
|
202
|
-
|
|
203
|
-
示例:
|
|
204
|
-
|
|
205
|
-
```json
|
|
206
|
-
{ "service": "codex" }
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
```json
|
|
210
|
-
{ "capabilities": { "services": ["claude"], "platforms": ["claude-code", "opencode"] } }
|
|
211
72
|
```
|
|
212
73
|
|
|
213
|
-
|
|
74
|
+
Web UI 默认地址是 `http://localhost:34020/`。需要时可以设置 `PORT`、`ADMIN_PASSWORD`、`NEWAPI_BASE_URL`、`NEWAPI_API_KEY`、`CLIPROXY_API_BASE` 或 `CLIPROXY_UPSTREAM_CONFIG`。
|
|
214
75
|
|
|
215
|
-
##
|
|
76
|
+
## 项目链接
|
|
216
77
|
|
|
217
|
-
-
|
|
218
|
-
-
|
|
219
|
-
- OpenCode:`~/.config/opencode/opencode.json`
|
|
220
|
-
- OpenClaw:`~/.openclaw/openclaw.json`
|
|
78
|
+
- GitHub: https://github.com/FogMaly/fogact
|
|
79
|
+
- npm: https://www.npmjs.com/package/fogact
|
|
221
80
|
- 备份目录:`~/.fogact/backups/`
|
|
222
81
|
|
|
223
82
|
## 开发
|
|
@@ -227,18 +86,3 @@ npm install
|
|
|
227
86
|
npm test
|
|
228
87
|
npm run web
|
|
229
88
|
```
|
|
230
|
-
|
|
231
|
-
项目结构:
|
|
232
|
-
|
|
233
|
-
- `bin/`:CLI 和 Web 服务入口
|
|
234
|
-
- `lib/`:命令、服务、平台和配置实现
|
|
235
|
-
- `frontend/`:静态前端资源
|
|
236
|
-
- `install.sh`:全新 VPS bootstrap 安装脚本
|
|
237
|
-
- `docs/`:实现说明和交付文档
|
|
238
|
-
- `scripts/`:辅助脚本
|
|
239
|
-
- `test/`:轻量测试脚本
|
|
240
|
-
- `data/`:本地运行数据,不提交仓库
|
|
241
|
-
|
|
242
|
-
## License
|
|
243
|
-
|
|
244
|
-
MIT. See `LICENSE`.
|
package/install.sh
CHANGED
|
@@ -359,20 +359,11 @@ run_activation() {
|
|
|
359
359
|
print_next_steps() {
|
|
360
360
|
cat <<EOF
|
|
361
361
|
|
|
362
|
-
Next
|
|
363
|
-
fogact
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
fogact
|
|
367
|
-
|
|
368
|
-
For code mode with a remote activation backend:
|
|
369
|
-
export CLIPROXY_API_BASE="https://your-activator.example.com"
|
|
370
|
-
fogact wizard --code YOUR_CODE --yes
|
|
371
|
-
|
|
372
|
-
For direct NewAPI mode:
|
|
373
|
-
export NEWAPI_BASE_URL="https://newapi.example.com"
|
|
374
|
-
export NEWAPI_API_KEY="sk-your-key"
|
|
375
|
-
fogact activate --service codex --yes
|
|
362
|
+
Next command:
|
|
363
|
+
fogact
|
|
364
|
+
|
|
365
|
+
This opens the same interactive activation menu as:
|
|
366
|
+
npx fogact
|
|
376
367
|
EOF
|
|
377
368
|
}
|
|
378
369
|
|
package/lib/index.js
CHANGED
|
@@ -9,8 +9,22 @@ const { runRestoreCommand } = require("./commands/restore");
|
|
|
9
9
|
const { runActivationWizard } = require("./services/activation-orchestrator");
|
|
10
10
|
|
|
11
11
|
function printBanner() {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const version = packageJson.version;
|
|
13
|
+
const title = `FogAct 激活器 v${version}`;
|
|
14
|
+
const displayWidth = (value) => Array.from(value).reduce((width, char) => {
|
|
15
|
+
return width + (char.charCodeAt(0) > 0xff ? 2 : 1);
|
|
16
|
+
}, 0);
|
|
17
|
+
const padLine = (value, width) => {
|
|
18
|
+
const padding = Math.max(0, width - displayWidth(value));
|
|
19
|
+
const left = Math.floor(padding / 2);
|
|
20
|
+
const right = padding - left;
|
|
21
|
+
return `${" ".repeat(left)}${value}${" ".repeat(right)}`;
|
|
22
|
+
};
|
|
23
|
+
console.log("");
|
|
24
|
+
console.log(" ╭─────────────────────────────────────╮");
|
|
25
|
+
console.log(` │${padLine(title, 37)}│`);
|
|
26
|
+
console.log(" │ Claude Code / Codex 配置工具 │");
|
|
27
|
+
console.log(" ╰─────────────────────────────────────╯");
|
|
14
28
|
console.log("");
|
|
15
29
|
}
|
|
16
30
|
|
|
@@ -25,13 +39,13 @@ async function runToolsMenu() {
|
|
|
25
39
|
{
|
|
26
40
|
type: "select",
|
|
27
41
|
name: "action",
|
|
28
|
-
message: "
|
|
42
|
+
message: "请选择操作:",
|
|
43
|
+
hint: "↑↓ 选择,回车确认",
|
|
29
44
|
choices: [
|
|
30
|
-
{ title: "
|
|
31
|
-
{ title: "测试节点", value: "test" },
|
|
32
|
-
{ title: "恢复备份", value: "restore" },
|
|
33
|
-
{ title: "
|
|
34
|
-
{ title: "退出", value: "exit" },
|
|
45
|
+
{ title: "1. 激活服务", value: "activate" },
|
|
46
|
+
{ title: "2. 测试节点", value: "test" },
|
|
47
|
+
{ title: "3. 恢复备份", value: "restore" },
|
|
48
|
+
{ title: "4. 退出", value: "exit" },
|
|
35
49
|
],
|
|
36
50
|
initial: 0,
|
|
37
51
|
},
|
|
@@ -48,10 +62,8 @@ async function runToolsMenu() {
|
|
|
48
62
|
case "restore":
|
|
49
63
|
await runRestoreCommand();
|
|
50
64
|
break;
|
|
51
|
-
case "web":
|
|
52
|
-
runWebServer();
|
|
53
|
-
break;
|
|
54
65
|
default:
|
|
66
|
+
console.log("");
|
|
55
67
|
console.log("再见。");
|
|
56
68
|
console.log("");
|
|
57
69
|
break;
|
|
@@ -76,11 +88,7 @@ function buildProgram() {
|
|
|
76
88
|
"Examples:",
|
|
77
89
|
" npx fogact",
|
|
78
90
|
" fogact",
|
|
79
|
-
" fogact
|
|
80
|
-
" fogact activate --service claude --api-key sk-... --yes",
|
|
81
|
-
" fogact activate --code K1DHPY3P-4B2W-F1A4-DC4P-Y74TCQZXPNYT",
|
|
82
|
-
" fogact test",
|
|
83
|
-
" fogact restore --service claude",
|
|
91
|
+
" fogact web",
|
|
84
92
|
].join("\n")
|
|
85
93
|
);
|
|
86
94
|
|
|
@@ -144,7 +152,7 @@ function buildProgram() {
|
|
|
144
152
|
}
|
|
145
153
|
|
|
146
154
|
async function runCli(argv = process.argv) {
|
|
147
|
-
const args = argv.slice(2);
|
|
155
|
+
const args = argv.slice(2).filter((arg) => arg !== "--help" && arg !== "-h");
|
|
148
156
|
|
|
149
157
|
if (args.length === 0) {
|
|
150
158
|
await runToolsMenu();
|
|
@@ -203,6 +203,7 @@ async function promptService(defaultService, entitlement = normalizeEntitlement(
|
|
|
203
203
|
type: "select",
|
|
204
204
|
name: "service",
|
|
205
205
|
message: "请选择要激活的能力",
|
|
206
|
+
hint: "↑↓ 选择,回车确认",
|
|
206
207
|
choices: allowedServices.map((service) => ({ title: getServiceLabel(service), value: service })),
|
|
207
208
|
initial: 0,
|
|
208
209
|
}, { onCancel: () => false });
|
|
@@ -267,9 +268,10 @@ async function promptCredentialType(options, upstream) {
|
|
|
267
268
|
type: "select",
|
|
268
269
|
name: "credentialType",
|
|
269
270
|
message: "请选择激活方式",
|
|
271
|
+
hint: "↑↓ 选择,回车确认",
|
|
270
272
|
choices: [
|
|
271
|
-
{ title: "输入 NewAPI API Key", value: "api-key" },
|
|
272
273
|
{ title: "输入激活码 / 兑换码", value: "code" },
|
|
274
|
+
{ title: "输入 NewAPI API Key", value: "api-key" },
|
|
273
275
|
],
|
|
274
276
|
initial: 0,
|
|
275
277
|
}, { onCancel: () => false });
|
|
@@ -312,8 +314,8 @@ function getBackupPaths(targets) {
|
|
|
312
314
|
function printBanner() {
|
|
313
315
|
console.log("");
|
|
314
316
|
console.log("╭────────────────────────────────────────╮");
|
|
315
|
-
console.log("│
|
|
316
|
-
console.log("│
|
|
317
|
+
console.log("│ FogAct 激活向导 │");
|
|
318
|
+
console.log("│ Claude Code / Codex 配置工具 │");
|
|
317
319
|
console.log("╰────────────────────────────────────────╯");
|
|
318
320
|
console.log("");
|
|
319
321
|
}
|
|
@@ -578,6 +580,23 @@ async function runNewApiActivation(options = {}) {
|
|
|
578
580
|
async function runActivationWizard(options = {}) {
|
|
579
581
|
printBanner();
|
|
580
582
|
const baseUpstream = loadUpstreamConfig({ configPath: options.upstreamConfig });
|
|
583
|
+
|
|
584
|
+
const service = await promptService(options.service, normalizeEntitlement());
|
|
585
|
+
if (!service) {
|
|
586
|
+
console.log("已取消。");
|
|
587
|
+
return { success: false, cancelled: true };
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const initialDetectedPlatforms = detectPlatforms(service);
|
|
591
|
+
console.log("");
|
|
592
|
+
printDetection(service, initialDetectedPlatforms);
|
|
593
|
+
|
|
594
|
+
const initialTargets = await selectPlatforms(initialDetectedPlatforms, options);
|
|
595
|
+
if (initialTargets.length === 0) {
|
|
596
|
+
console.log("没有选择任何平台,已取消。");
|
|
597
|
+
return { success: false, cancelled: true };
|
|
598
|
+
}
|
|
599
|
+
|
|
581
600
|
const credentialType = await promptCredentialType(options, baseUpstream);
|
|
582
601
|
if (!credentialType) {
|
|
583
602
|
console.log("已取消。");
|
|
@@ -599,12 +618,6 @@ async function runActivationWizard(options = {}) {
|
|
|
599
618
|
return { success: false, cancelled: true };
|
|
600
619
|
}
|
|
601
620
|
|
|
602
|
-
const service = await promptService(options.service, credential.entitlement);
|
|
603
|
-
if (!service) {
|
|
604
|
-
console.log("已取消。");
|
|
605
|
-
return { success: false, cancelled: true };
|
|
606
|
-
}
|
|
607
|
-
|
|
608
621
|
console.log("");
|
|
609
622
|
if (credentialType === "api-key") {
|
|
610
623
|
const verification = await verifyCredential(upstream, credential.apiKey, options);
|
|
@@ -618,16 +631,14 @@ async function runActivationWizard(options = {}) {
|
|
|
618
631
|
const allDetectedPlatforms = detectPlatforms(service);
|
|
619
632
|
const allowedPlatforms = allDetectedPlatforms.filter((entry) => isPlatformAllowed(entry, credential.entitlement, service));
|
|
620
633
|
const blockedPlatforms = allDetectedPlatforms.filter((entry) => !allowedPlatforms.includes(entry));
|
|
634
|
+
const initialTargetIds = new Set(initialTargets.map(({ platform }) => platform.id));
|
|
621
635
|
|
|
622
|
-
|
|
623
|
-
printDetection(service, allowedPlatforms, blockedPlatforms);
|
|
624
|
-
|
|
625
|
-
const targets = await selectPlatforms(allowedPlatforms, options);
|
|
636
|
+
const targets = allowedPlatforms.filter((entry) => initialTargetIds.has(entry.platform.id));
|
|
626
637
|
if (targets.length === 0) {
|
|
627
|
-
console.log("
|
|
638
|
+
console.log("当前激活能力不包含已选择的平台,已取消。");
|
|
628
639
|
return { success: false, cancelled: true };
|
|
629
640
|
}
|
|
630
|
-
const skipped =
|
|
641
|
+
const skipped = allDetectedPlatforms.filter((entry) => !targets.includes(entry) || blockedPlatforms.includes(entry));
|
|
631
642
|
|
|
632
643
|
printPlan(service, upstream, credential.apiKey, targets, skipped);
|
|
633
644
|
if (!(await confirmActivation(Boolean(options.yes || options.auto)))) {
|
package/lib/services/newapi.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fogact",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "FogAct
|
|
3
|
+
"version": "1.1.5",
|
|
4
|
+
"description": "FogAct activation helper for Claude Code and Codex",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fogact",
|
|
7
7
|
"cliproxy",
|