opencode-copilot-account-switcher 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jiwangyihao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,249 @@
1
+ # OpenCode GitHub Copilot Account Switcher
2
+
3
+ [![npm version](https://img.shields.io/npm/v/opencode-copilot-account-switcher.svg)](https://www.npmjs.com/package/opencode-copilot-account-switcher)
4
+ [![npm downloads](https://img.shields.io/npm/dw/opencode-copilot-account-switcher.svg)](https://www.npmjs.com/package/opencode-copilot-account-switcher)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+
7
+ [English](#english) | [中文](#中文)
8
+
9
+ ---
10
+
11
+ <a name="english"></a>
12
+
13
+ ## English
14
+
15
+ Manage and switch between multiple **GitHub Copilot** accounts in **OpenCode**. This plugin only adds account switching and quota checks — it **uses the official `github-copilot` provider** and does **not** require model reconfiguration.
16
+
17
+ ## What You Get
18
+
19
+ - **Multi-account support** — add multiple Copilot accounts and switch anytime
20
+ - **Quota check** — view remaining quota per account
21
+ - **Auth import** — import Copilot tokens from OpenCode auth storage
22
+ - **Zero model config** — no model changes required (official provider only)
23
+
24
+ ---
25
+
26
+ ## Installation
27
+
28
+ <details open>
29
+ <summary><b>For Humans</b></summary>
30
+
31
+ **Option A: Let an LLM do it**
32
+
33
+ Paste this into any LLM agent (OpenCode, Claude Code, Cursor, etc.):
34
+
35
+ ```
36
+ Install the opencode-copilot-account-switcher plugin by following: https://raw.githubusercontent.com/jiwangyihao/opencode-copilot-account-switcher/master/README.md
37
+ ```
38
+
39
+ **Option B: Manual setup**
40
+
41
+ 1. **Add the plugin** to `~/.config/opencode/opencode.json`:
42
+
43
+ ```json
44
+ {
45
+ "$schema": "https://opencode.ai/config.json",
46
+ "plugin": ["opencode-copilot-account-switcher"]
47
+ }
48
+ ```
49
+
50
+ 2. **Restart OpenCode** (it will auto-download the plugin from npm).
51
+
52
+ 3. **Login** to GitHub Copilot:
53
+
54
+ ```bash
55
+ opencode auth login github-copilot
56
+ ```
57
+
58
+ </details>
59
+
60
+ <details>
61
+ <summary><b>For LLM Agents</b></summary>
62
+
63
+ ### Step-by-Step Instructions
64
+
65
+ 1. Edit the OpenCode configuration file at `~/.config/opencode/opencode.json`
66
+
67
+ > **Note**: This path works on all platforms. On Windows, `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
68
+
69
+ 2. Add the plugin to the `plugin` array:
70
+
71
+ ```json
72
+ {
73
+ "$schema": "https://opencode.ai/config.json",
74
+ "plugin": ["opencode-copilot-account-switcher"]
75
+ }
76
+ ```
77
+
78
+ 3. Restart OpenCode so it fetches the plugin automatically from npm.
79
+
80
+ ### Verification
81
+
82
+ ```bash
83
+ opencode auth login github-copilot
84
+ ```
85
+
86
+ </details>
87
+
88
+ ---
89
+
90
+ ## Usage
91
+
92
+ Run inside the GitHub Copilot auth flow:
93
+
94
+ ```bash
95
+ opencode auth login github-copilot
96
+ ```
97
+
98
+ You will see an interactive menu (arrow keys + enter) with actions:
99
+
100
+ - **Add account**
101
+ - **Import from auth.json**
102
+ - **Check quotas**
103
+ - **Switch account**
104
+ - **Remove account**
105
+ - **Remove all**
106
+
107
+ ---
108
+
109
+ ## Storage
110
+
111
+ Accounts are stored in:
112
+
113
+ ```
114
+ ~/.config/opencode/copilot-accounts.json
115
+ ```
116
+
117
+ ---
118
+
119
+ ## FAQ
120
+
121
+ **Do I need to change model configurations?**
122
+ No. This plugin only manages accounts and works with the official `github-copilot` provider.
123
+
124
+ **Does it replace the official provider?**
125
+ No. It uses the official provider and only adds account switching + quota checks.
126
+
127
+ ---
128
+
129
+ <a name="中文"></a>
130
+
131
+ ## 中文
132
+
133
+ 在 **OpenCode** 中管理并切换多个 **GitHub Copilot** 账号。本插件只提供**账号切换与配额查询**,**完全依赖官方 `github-copilot` provider**,无需修改模型配置。
134
+
135
+ ## 功能一览
136
+
137
+ - **多账号管理** — 添加多个 Copilot 账号,随时切换
138
+ - **配额查询** — 查看每个账号的剩余额度
139
+ - **导入认证** — 可从 OpenCode 认证存储导入
140
+ - **无需模型配置** — 使用官方 provider,无需改模型
141
+
142
+ ---
143
+
144
+ ## 安装
145
+
146
+ <details open>
147
+ <summary><b>面向人类用户</b></summary>
148
+
149
+ **选项 A:让 LLM 帮你安装**
150
+
151
+ 把下面这段话丢给任意 LLM(OpenCode / Claude Code / Cursor 等):
152
+
153
+ ```
154
+ 请按以下说明安装 opencode-copilot-account-switcher 插件:https://raw.githubusercontent.com/jiwangyihao/opencode-copilot-account-switcher/master/README.md
155
+ ```
156
+
157
+ **选项 B:手动安装**
158
+
159
+ 1. **在配置文件中添加插件** `~/.config/opencode/opencode.json`:
160
+
161
+ ```json
162
+ {
163
+ "$schema": "https://opencode.ai/config.json",
164
+ "plugin": ["opencode-copilot-account-switcher"]
165
+ }
166
+ ```
167
+
168
+ 2. **重启 OpenCode**(会自动从 npm 下载插件)。
169
+
170
+ 3. **登录 GitHub Copilot**:
171
+
172
+ ```bash
173
+ opencode auth login github-copilot
174
+ ```
175
+
176
+ </details>
177
+
178
+ <details>
179
+ <summary><b>面向 LLM 智能体</b></summary>
180
+
181
+ ### 步骤指引
182
+
183
+ 1. 打开 OpenCode 配置文件 `~/.config/opencode/opencode.json`
184
+
185
+ > **说明**:该路径在所有平台通用;Windows 上 `~` 会解析为用户目录(例如 `C:\Users\YourName`)。
186
+
187
+ 2. 在 `plugin` 数组中添加插件:
188
+
189
+ ```json
190
+ {
191
+ "$schema": "https://opencode.ai/config.json",
192
+ "plugin": ["opencode-copilot-account-switcher"]
193
+ }
194
+ ```
195
+
196
+ 3. 重启 OpenCode,使其自动拉取 npm 包。
197
+
198
+ ### 验证
199
+
200
+ ```bash
201
+ opencode auth login github-copilot
202
+ ```
203
+
204
+ </details>
205
+
206
+ ---
207
+
208
+ ## 使用方式
209
+
210
+ 在 Copilot 认证流程中运行:
211
+
212
+ ```bash
213
+ opencode auth login github-copilot
214
+ ```
215
+
216
+ 会出现交互式菜单(方向键 + 回车):
217
+
218
+ - **添加账号**
219
+ - **从 auth.json 导入**
220
+ - **检查配额**
221
+ - **切换账号**
222
+ - **删除账号**
223
+ - **全部删除**
224
+
225
+ ---
226
+
227
+ ## 存储位置
228
+
229
+ 账号信息保存于:
230
+
231
+ ```
232
+ ~/.config/opencode/copilot-accounts.json
233
+ ```
234
+
235
+ ---
236
+
237
+ ## 常见问题
238
+
239
+ **需要改模型配置吗?**
240
+ 不需要。本插件只做账号管理,继续使用官方 `github-copilot` provider。
241
+
242
+ **会替换官方 provider 吗?**
243
+ 不会。它只是在官方 provider 基础上增加账号切换和配额查询。
244
+
245
+ ---
246
+
247
+ ## License
248
+
249
+ MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1 @@
1
+ export { CopilotAccountSwitcher } from "./plugin";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { CopilotAccountSwitcher } from "./plugin";
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from "@opencode-ai/plugin";
2
+ export declare const CopilotAccountSwitcher: Plugin;