opencode-copilot-account-switcher 0.2.6 → 0.2.8

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 CHANGED
@@ -4,43 +4,43 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dw/opencode-copilot-account-switcher.svg)](https://www.npmjs.com/package/opencode-copilot-account-switcher)
5
5
  [![License: MPL-2.0](https://img.shields.io/badge/License-MPL--2.0-brightgreen.svg)](LICENSE)
6
6
 
7
- [English](#english) | [中文](#中文)
7
+ [中文](#中文) | [English](#english)
8
8
 
9
9
  ---
10
10
 
11
- <a name="english"></a>
11
+ <a name="中文"></a>
12
12
 
13
- ## English
13
+ ## 中文
14
14
 
15
- Manage and switch between multiple **GitHub Copilot** accounts in **OpenCode**. This plugin adds account switching, quota checks, an optional **Guided Loop Safety** mode that can keep a single premium request productive for hours with fewer report interruptions before it truly needs user input, and an optional **Copilot Network Retry** switch for retryable network and certificate failures. It **uses the official `github-copilot` provider** and does **not** require model reconfiguration.
15
+ **OpenCode** 中管理并切换多个 **GitHub Copilot** 账号。本插件提供**账号切换、配额查询**、默认开启的 **Guided Loop Safety** 模式,以及默认关闭的 **Copilot Network Retry** 开关;前者帮助一次 premium request 更容易连续工作好几个小时、减少真正需要你输入之前的汇报打断,后者用于处理可重试的网络与证书类失败。**完全依赖官方 `github-copilot` provider**,无需修改模型配置。
16
16
 
17
- ## What You Get
17
+ ## 功能一览
18
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
- - **Guided Loop Safety** — a stricter Copilot-only question-first policy designed to keep non-blocked work moving, keep one premium request productive for hours, and cut avoidable quota burn by replacing repeated interruption turns with `question`-based waiting
23
- - **Copilot Network Retry** — optional and off by default; normalizes retryable Copilot network or TLS failures so OpenCode's native retry path can handle them
24
- - **Zero model config** no model changes required (official provider only)
19
+ - **多账号管理**添加多个 Copilot 账号,随时切换
20
+ - **配额查询**查看每个账号的剩余额度
21
+ - **导入认证**可从 OpenCode 认证存储导入
22
+ - **Guided Loop Safety** — 默认开启;仅对 Copilot 生效的更严格 question-first 提示词策略,推动非阻塞工作持续执行、让一次 premium request 更容易连续工作好几个小时,并通过减少反复中断来降低无谓配额消耗
23
+ - **Copilot Network Retry** — 默认关闭;把可重试的 Copilot 网络或 TLS 失败归一化成 OpenCode 原生重试链路可识别的形态
24
+ - **无需模型配置**使用官方 provider,无需改模型
25
25
 
26
26
  ---
27
27
 
28
- ## Installation
28
+ ## 安装
29
29
 
30
30
  <details open>
31
- <summary><b>For Humans</b></summary>
31
+ <summary><b>面向人类用户</b></summary>
32
32
 
33
- **Option A: Let an LLM do it**
33
+ **选项 A:让 LLM 帮你安装**
34
34
 
35
- Paste this into any LLM agent (OpenCode, Claude Code, Cursor, etc.):
35
+ 把下面这段话丢给任意 LLM(OpenCode / Claude Code / Cursor 等):
36
36
 
37
37
  ```
38
- Install the opencode-copilot-account-switcher plugin by following: https://raw.githubusercontent.com/jiwangyihao/opencode-copilot-account-switcher/master/README.md
38
+ 请按以下说明安装 opencode-copilot-account-switcher 插件:https://raw.githubusercontent.com/jiwangyihao/opencode-copilot-account-switcher/master/README.md
39
39
  ```
40
40
 
41
- **Option B: Manual setup**
41
+ **选项 B:手动安装**
42
42
 
43
- 1. **Add the plugin** to `~/.config/opencode/opencode.json`:
43
+ 1. **在配置文件中添加插件** `~/.config/opencode/opencode.json`:
44
44
 
45
45
  ```json
46
46
  {
@@ -49,9 +49,9 @@ Install the opencode-copilot-account-switcher plugin by following: https://raw.g
49
49
  }
50
50
  ```
51
51
 
52
- 2. **Restart OpenCode** (it will auto-download the plugin from npm).
52
+ 2. **重启 OpenCode**(会自动从 npm 下载插件)。
53
53
 
54
- 3. **Login** to GitHub Copilot:
54
+ 3. **登录 GitHub Copilot**:
55
55
 
56
56
  ```bash
57
57
  opencode auth login --provider github-copilot
@@ -60,15 +60,15 @@ Install the opencode-copilot-account-switcher plugin by following: https://raw.g
60
60
  </details>
61
61
 
62
62
  <details>
63
- <summary><b>For LLM Agents</b></summary>
63
+ <summary><b>面向 LLM 智能体</b></summary>
64
64
 
65
- ### Step-by-Step Instructions
65
+ ### 步骤指引
66
66
 
67
- 1. Edit the OpenCode configuration file at `~/.config/opencode/opencode.json`
67
+ 1. 打开 OpenCode 配置文件 `~/.config/opencode/opencode.json`
68
68
 
69
- > **Note**: This path works on all platforms. On Windows, `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
69
+ > **说明**:该路径在所有平台通用;Windows `~` 会解析为用户目录(例如 `C:\Users\YourName`)。
70
70
 
71
- 2. Add the plugin to the `plugin` array:
71
+ 2. `plugin` 数组中添加插件:
72
72
 
73
73
  ```json
74
74
  {
@@ -77,9 +77,9 @@ Install the opencode-copilot-account-switcher plugin by following: https://raw.g
77
77
  }
78
78
  ```
79
79
 
80
- 3. Restart OpenCode so it fetches the plugin automatically from npm.
80
+ 3. 重启 OpenCode,使其自动拉取 npm 包。
81
81
 
82
- ### Verification
82
+ ### 验证
83
83
 
84
84
  ```bash
85
85
  opencode auth login --provider github-copilot
@@ -89,55 +89,55 @@ opencode auth login --provider github-copilot
89
89
 
90
90
  ---
91
91
 
92
- ## Usage
92
+ ## 使用方式
93
93
 
94
- Run inside the GitHub Copilot auth flow:
94
+ Copilot 认证流程中运行:
95
95
 
96
96
  ```bash
97
97
  opencode auth login --provider github-copilot
98
98
  ```
99
99
 
100
- You will see an interactive menu (arrow keys + enter) with actions:
100
+ 会出现交互式菜单(方向键 + 回车):
101
101
 
102
- - **Add account**
103
- - **Import from auth.json**
104
- - **Check quotas**
105
- - **Guided Loop Safety**prompt-guided question-first reporting that requires `question` for user-facing reports when available, keeps non-blocked work moving, reduces repeated interruptions, and avoids unnecessary subagent calls
106
- - **Copilot Network Retry**off by default; only affects the Copilot request `fetch` path and only for retryable network/certificate-style failures
107
- - **Switch account**
108
- - **Remove account**
109
- - **Remove all**
102
+ - **添加账号**
103
+ - **从 auth.json 导入**
104
+ - **检查配额**
105
+ - **Guided Loop Safety 开关** 通过提示词引导模型在可用时必须使用 `question` 做用户可见汇报、继续完成非阻塞工作、减少反复中断,并避免不必要的子代理调用
106
+ - **Copilot Network Retry 开关** 默认关闭;仅影响 Copilot 请求的 `fetch` 路径,只处理可重试的网络/证书类失败
107
+ - **切换账号**
108
+ - **删除账号**
109
+ - **全部删除**
110
110
 
111
- If you want GitHub Copilot sessions to stay in a single premium request longer, enable Guided Loop Safety from the account menu. In practice, this can keep one request productive for hours: when `question` is available and permitted, user-facing reports must go through it, so waiting for your reply does not keep burning extra quota the way repeated direct-status interruptions do. Fewer interruptions also means less avoidable quota burn. If safe non-blocked work remains, Copilot should keep going instead of pausing early; only when no safe action remains should it use `question` to ask for the next task or clarification, while also reducing unnecessary subagent calls.
111
+ Guided Loop Safety 现在默认开启。实际使用中,它可以让一次 request 更容易连续工作好几个小时:当 `question` 工具在当前会话中可用且被允许时,用户可见汇报必须通过它完成,因此等待你的回复本身不会像反复插入直接状态消息那样继续额外消耗配额;少一次中断,本身就少一次无谓的配额消耗。只要还有安全的非阻塞工作可做,Copilot 就应继续执行而不是提前暂停;只有在当前确实没有可安全执行的动作时,才应通过 `question` 询问下一项任务或所需澄清,同时也会减少不必要的子代理调用。
112
112
 
113
- If you hit transient Copilot TLS or network failures, you can enable Copilot Network Retry from the same menu. It is off by default. When enabled, the plugin keeps the official Copilot header/baseURL behavior from the upstream loader, only wraps the final Copilot `fetch` path, and converts retryable network-like failures into a shape that OpenCode already treats as retryable. This keeps request retry policy aligned with OpenCode instead of re-implementing a second retry system inside the plugin.
113
+ 如果你在切换 Copilot 账号后遇到瞬时 TLS/网络失败,或者遇到由旧 session item ID 残留引起的 `input[*].id too long` 错误,也可以在同一菜单中开启 Copilot Network Retry。它默认关闭。开启后,插件会先保留 upstream 官方 loader 生成的 `baseURL`、认证头和 `fetch` 行为,只在最后一跳 Copilot `fetch` 路径上做最小包装,把可重试的网络类失败归一化成 OpenCode 已有重试链路能识别的形态;对于明确命中的 `input[*].id too long` 400,还会回写命中的 session part,避免旧 item ID 持续污染后续重试。
114
114
 
115
115
  ## Copilot Network Retry
116
116
 
117
- - Default: **disabled**
118
- - Scope: only the official Copilot request `fetch` path returned by `auth.loader`
119
- - Purpose: limited handling for retryable network and certificate-style failures such as `failed to fetch`, `ECONNRESET`, `unknown certificate`, or `self signed certificate`
120
- - Strategy: preserve official loader behavior, then normalize retryable failures so OpenCode's native retry pipeline can decide whether and when to retry
121
- - Risk: because the plugin still wraps the official fetch path, upstream internal behavior may change over time and drift is possible
117
+ - 默认:**关闭**
118
+ - 作用范围:仅影响 `auth.loader` 返回的官方 Copilot 请求 `fetch` 路径
119
+ - 用途:有限处理 `failed to fetch`、`ECONNRESET`、`unknown certificate`、`self signed certificate` 等可重试网络/证书类失败
120
+ - 实现策略:尽量保留官方 loader 行为,再把可重试失败归一化给 OpenCode 原生重试链路判断是否重试
121
+ - 风险提示:因为插件仍然包裹了官方 fetch 路径,若 upstream 后续内部实现变化,仍可能产生行为漂移
122
122
 
123
- ## Upstream Sync
123
+ ## Upstream 同步机制
124
124
 
125
- The repository includes a committed upstream snapshot at `src/upstream/copilot-plugin.snapshot.ts` plus a sync/check script at `scripts/sync-copilot-upstream.mjs`.
125
+ 仓库中提交了一份 upstream 快照 `src/upstream/copilot-plugin.snapshot.ts`,并提供同步/校验脚本 `scripts/sync-copilot-upstream.mjs`。
126
126
 
127
- Useful commands:
127
+ 常用命令:
128
128
 
129
129
  ```bash
130
130
  npm run sync:copilot-snapshot -- --source <file-or-url> --upstream-commit <sha> --sync-date <YYYY-MM-DD>
131
131
  npm run check:copilot-sync -- --source <file-or-url> --upstream-commit <sha> --sync-date <YYYY-MM-DD>
132
132
  ```
133
133
 
134
- The script generates or checks the committed snapshot, requires upstream metadata for repository snapshot updates, and helps catch drift from the official `opencode` `copilot.ts` implementation.
134
+ 该脚本会生成或校验仓库中提交的 snapshot,并要求在更新正式 snapshot 时显式提供 upstream commit 与同步日期,用来尽早发现与官方 `opencode` `copilot.ts` 的行为漂移。
135
135
 
136
136
  ---
137
137
 
138
- ## Storage
138
+ ## 存储位置
139
139
 
140
- Accounts are stored in:
140
+ 账号信息保存于:
141
141
 
142
142
  ```
143
143
  ~/.config/opencode/copilot-accounts.json
@@ -145,52 +145,52 @@ Accounts are stored in:
145
145
 
146
146
  ---
147
147
 
148
- ## FAQ
148
+ ## 常见问题
149
149
 
150
- **Do I need to change model configurations?**
151
- No. This plugin only manages accounts and works with the official `github-copilot` provider.
150
+ **需要改模型配置吗?**
151
+ 不需要。本插件只做账号管理,继续使用官方 `github-copilot` provider
152
152
 
153
- **Does it replace the official provider?**
154
- No. It uses the official provider and only adds account switching + quota checks.
153
+ **会替换官方 provider 吗?**
154
+ 不会。它只是在官方 provider 基础上增加账号切换和配额查询。
155
155
 
156
- **Does Copilot Network Retry replace OpenCode's retry logic?**
157
- No. The plugin keeps retry policy inside OpenCode by normalizing retryable Copilot network/TLS failures into a shape that OpenCode already recognizes as retryable.
156
+ **Copilot Network Retry 会替代 OpenCode 自己的重试逻辑吗?**
157
+ 不会。插件的目标是把可重试的 Copilot 网络/TLS 失败归一化成 OpenCode 已识别的可重试错误形态,真正的是否重试与如何退避仍由 OpenCode 原生链路决定。
158
158
 
159
159
  ---
160
160
 
161
- <a name="中文"></a>
161
+ <a name="english"></a>
162
162
 
163
- ## 中文
163
+ ## English
164
164
 
165
- **OpenCode** 中管理并切换多个 **GitHub Copilot** 账号。本插件提供**账号切换、配额查询**、可选的 **Guided Loop Safety** 模式,以及默认关闭的 **Copilot Network Retry** 开关;前者帮助一次 premium request 更容易连续工作好几个小时、减少真正需要你输入之前的汇报打断,后者用于处理可重试的网络与证书类失败。**完全依赖官方 `github-copilot` provider**,无需修改模型配置。
165
+ Manage and switch between multiple **GitHub Copilot** accounts in **OpenCode**. This plugin adds account switching, quota checks, a default-on **Guided Loop Safety** mode that can keep a single premium request productive for hours with fewer report interruptions before it truly needs user input, and an optional **Copilot Network Retry** switch for retryable network and certificate failures. It **uses the official `github-copilot` provider** and does **not** require model reconfiguration.
166
166
 
167
- ## 功能一览
167
+ ## What You Get
168
168
 
169
- - **多账号管理**添加多个 Copilot 账号,随时切换
170
- - **配额查询**查看每个账号的剩余额度
171
- - **导入认证**可从 OpenCode 认证存储导入
172
- - **Guided Loop Safety** — 仅对 Copilot 生效的更严格 question-first 提示词策略,推动非阻塞工作持续执行、让一次 premium request 更容易连续工作好几个小时,并通过减少反复中断来降低无谓配额消耗
173
- - **Copilot Network Retry** — 默认关闭;把可重试的 Copilot 网络或 TLS 失败归一化成 OpenCode 原生重试链路可识别的形态
174
- - **无需模型配置**使用官方 provider,无需改模型
169
+ - **Multi-account support** add multiple Copilot accounts and switch anytime
170
+ - **Quota check** view remaining quota per account
171
+ - **Auth import** import Copilot tokens from OpenCode auth storage
172
+ - **Guided Loop Safety** — enabled by default; a stricter Copilot-only question-first policy designed to keep non-blocked work moving, keep one premium request productive for hours, and cut avoidable quota burn by replacing repeated interruption turns with `question`-based waiting
173
+ - **Copilot Network Retry** — optional and off by default; normalizes retryable Copilot network or TLS failures so OpenCode's native retry path can handle them
174
+ - **Zero model config** no model changes required (official provider only)
175
175
 
176
176
  ---
177
177
 
178
- ## 安装
178
+ ## Installation
179
179
 
180
180
  <details open>
181
- <summary><b>面向人类用户</b></summary>
181
+ <summary><b>For Humans</b></summary>
182
182
 
183
- **选项 A:让 LLM 帮你安装**
183
+ **Option A: Let an LLM do it**
184
184
 
185
- 把下面这段话丢给任意 LLMOpenCode / Claude Code / Cursor 等):
185
+ Paste this into any LLM agent (OpenCode, Claude Code, Cursor, etc.):
186
186
 
187
187
  ```
188
- 请按以下说明安装 opencode-copilot-account-switcher 插件:https://raw.githubusercontent.com/jiwangyihao/opencode-copilot-account-switcher/master/README.md
188
+ Install the opencode-copilot-account-switcher plugin by following: https://raw.githubusercontent.com/jiwangyihao/opencode-copilot-account-switcher/master/README.md
189
189
  ```
190
190
 
191
- **选项 B:手动安装**
191
+ **Option B: Manual setup**
192
192
 
193
- 1. **在配置文件中添加插件** `~/.config/opencode/opencode.json`:
193
+ 1. **Add the plugin** to `~/.config/opencode/opencode.json`:
194
194
 
195
195
  ```json
196
196
  {
@@ -199,9 +199,9 @@ No. The plugin keeps retry policy inside OpenCode by normalizing retryable Copil
199
199
  }
200
200
  ```
201
201
 
202
- 2. **重启 OpenCode**(会自动从 npm 下载插件)。
202
+ 2. **Restart OpenCode** (it will auto-download the plugin from npm).
203
203
 
204
- 3. **登录 GitHub Copilot**:
204
+ 3. **Login** to GitHub Copilot:
205
205
 
206
206
  ```bash
207
207
  opencode auth login --provider github-copilot
@@ -210,15 +210,15 @@ No. The plugin keeps retry policy inside OpenCode by normalizing retryable Copil
210
210
  </details>
211
211
 
212
212
  <details>
213
- <summary><b>面向 LLM 智能体</b></summary>
213
+ <summary><b>For LLM Agents</b></summary>
214
214
 
215
- ### 步骤指引
215
+ ### Step-by-Step Instructions
216
216
 
217
- 1. 打开 OpenCode 配置文件 `~/.config/opencode/opencode.json`
217
+ 1. Edit the OpenCode configuration file at `~/.config/opencode/opencode.json`
218
218
 
219
- > **说明**:该路径在所有平台通用;Windows `~` 会解析为用户目录(例如 `C:\Users\YourName`)。
219
+ > **Note**: This path works on all platforms. On Windows, `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
220
220
 
221
- 2. `plugin` 数组中添加插件:
221
+ 2. Add the plugin to the `plugin` array:
222
222
 
223
223
  ```json
224
224
  {
@@ -227,9 +227,9 @@ No. The plugin keeps retry policy inside OpenCode by normalizing retryable Copil
227
227
  }
228
228
  ```
229
229
 
230
- 3. 重启 OpenCode,使其自动拉取 npm 包。
230
+ 3. Restart OpenCode so it fetches the plugin automatically from npm.
231
231
 
232
- ### 验证
232
+ ### Verification
233
233
 
234
234
  ```bash
235
235
  opencode auth login --provider github-copilot
@@ -239,55 +239,46 @@ opencode auth login --provider github-copilot
239
239
 
240
240
  ---
241
241
 
242
- ## 使用方式
242
+ ## Usage
243
243
 
244
- Copilot 认证流程中运行:
244
+ Run inside the GitHub Copilot auth flow:
245
245
 
246
246
  ```bash
247
247
  opencode auth login --provider github-copilot
248
248
  ```
249
249
 
250
- 会出现交互式菜单(方向键 + 回车):
251
-
252
- - **添加账号**
253
- - **从 auth.json 导入**
254
- - **检查配额**
255
- - **Guided Loop Safety 开关** — 通过提示词引导模型在可用时必须使用 `question` 做用户可见汇报、继续完成非阻塞工作、减少反复中断,并避免不必要的子代理调用
256
- - **Copilot Network Retry 开关** — 默认关闭;仅影响 Copilot 请求的 `fetch` 路径,只处理可重试的网络/证书类失败
257
- - **切换账号**
258
- - **删除账号**
259
- - **全部删除**
250
+ You will see an interactive menu. Use the built-in language switch action if you want to swap between Chinese and English labels.
260
251
 
261
- 如果你希望 GitHub Copilot 会话在一次 premium request 中尽量持续工作、更少被汇报打断,可以在账号菜单中开启 Guided Loop Safety。实际使用中,它可以让一次 request 更容易连续工作好几个小时:当 `question` 工具在当前会话中可用且被允许时,用户可见汇报必须通过它完成,因此等待你的回复本身不会像反复插入直接状态消息那样继续额外消耗配额;少一次中断,本身就少一次无谓的配额消耗。只要还有安全的非阻塞工作可做,Copilot 就应继续执行而不是提前暂停;只有在当前确实没有可安全执行的动作时,才应通过 `question` 询问下一项任务或所需澄清,同时也会减少不必要的子代理调用。
252
+ Guided Loop Safety is enabled by default. In practice, this can keep one request productive for hours: when `question` is available and permitted, user-facing reports must go through it, so waiting for your reply does not keep burning extra quota the way repeated direct-status interruptions do. Fewer interruptions also means less avoidable quota burn. If safe non-blocked work remains, Copilot should keep going instead of pausing early; only when no safe action remains should it use `question` to ask for the next task or clarification, while also reducing unnecessary subagent calls.
262
253
 
263
- 如果你遇到 Copilot 的瞬时 TLS 或网络失败,也可以在同一菜单中开启 Copilot Network Retry。它默认关闭。开启后,插件会先保留 upstream 官方 loader 生成的 `baseURL`、认证头和 `fetch` 行为,只在最后一跳 Copilot `fetch` 路径上做最小包装,把可重试的网络类失败归一化成 OpenCode 已有重试链路能识别的形态,而不是在插件内部重新定义一套独立的请求重试策略。
254
+ If you switch Copilot accounts and then hit transient TLS/network failures or `input[*].id too long` errors caused by stale session item IDs, enable Copilot Network Retry from the same menu. It is off by default. When enabled, the plugin keeps the official Copilot header/baseURL behavior from the upstream loader, only wraps the final Copilot `fetch` path, and converts retryable network-like failures into a shape that OpenCode already treats as retryable. It also repairs the matched session part after an `input[*].id too long` 400 so later retries can recover instead of repeatedly failing on stale item IDs.
264
255
 
265
256
  ## Copilot Network Retry
266
257
 
267
- - 默认:**关闭**
268
- - 作用范围:仅影响 `auth.loader` 返回的官方 Copilot 请求 `fetch` 路径
269
- - 用途:有限处理 `failed to fetch`、`ECONNRESET`、`unknown certificate`、`self signed certificate` 等可重试网络/证书类失败
270
- - 实现策略:尽量保留官方 loader 行为,再把可重试失败归一化给 OpenCode 原生重试链路判断是否重试
271
- - 风险提示:因为插件仍然包裹了官方 fetch 路径,若 upstream 后续内部实现变化,仍可能产生行为漂移
258
+ - Default: **disabled**
259
+ - Scope: only the official Copilot request `fetch` path returned by `auth.loader`
260
+ - Purpose: limited handling for retryable network and certificate-style failures such as `failed to fetch`, `ECONNRESET`, `unknown certificate`, or `self signed certificate`
261
+ - Strategy: preserve official loader behavior, then normalize retryable failures so OpenCode's native retry pipeline can decide whether and when to retry
262
+ - Risk: because the plugin still wraps the official fetch path, upstream internal behavior may change over time and drift is possible
272
263
 
273
- ## Upstream 同步机制
264
+ ## Upstream Sync
274
265
 
275
- 仓库中提交了一份 upstream 快照 `src/upstream/copilot-plugin.snapshot.ts`,并提供同步/校验脚本 `scripts/sync-copilot-upstream.mjs`。
266
+ The repository includes a committed upstream snapshot at `src/upstream/copilot-plugin.snapshot.ts` plus a sync/check script at `scripts/sync-copilot-upstream.mjs`.
276
267
 
277
- 常用命令:
268
+ Useful commands:
278
269
 
279
270
  ```bash
280
271
  npm run sync:copilot-snapshot -- --source <file-or-url> --upstream-commit <sha> --sync-date <YYYY-MM-DD>
281
272
  npm run check:copilot-sync -- --source <file-or-url> --upstream-commit <sha> --sync-date <YYYY-MM-DD>
282
273
  ```
283
274
 
284
- 该脚本会生成或校验仓库中提交的 snapshot,并要求在更新正式 snapshot 时显式提供 upstream commit 与同步日期,用来尽早发现与官方 `opencode` `copilot.ts` 的行为漂移。
275
+ The script generates or checks the committed snapshot, requires upstream metadata for repository snapshot updates, and helps catch drift from the official `opencode` `copilot.ts` implementation.
285
276
 
286
277
  ---
287
278
 
288
- ## 存储位置
279
+ ## Storage
289
280
 
290
- 账号信息保存于:
281
+ Accounts are stored in:
291
282
 
292
283
  ```
293
284
  ~/.config/opencode/copilot-accounts.json
@@ -295,16 +286,16 @@ npm run check:copilot-sync -- --source <file-or-url> --upstream-commit <sha> --s
295
286
 
296
287
  ---
297
288
 
298
- ## 常见问题
289
+ ## FAQ
299
290
 
300
- **需要改模型配置吗?**
301
- 不需要。本插件只做账号管理,继续使用官方 `github-copilot` provider
291
+ **Do I need to change model configurations?**
292
+ No. This plugin only manages accounts and works with the official `github-copilot` provider.
302
293
 
303
- **会替换官方 provider 吗?**
304
- 不会。它只是在官方 provider 基础上增加账号切换和配额查询。
294
+ **Does it replace the official provider?**
295
+ No. It uses the official provider and only adds account switching + quota checks.
305
296
 
306
- **Copilot Network Retry 会替代 OpenCode 自己的重试逻辑吗?**
307
- 不会。插件的目标是把可重试的 Copilot 网络/TLS 失败归一化成 OpenCode 已识别的可重试错误形态,真正的是否重试与如何退避仍由 OpenCode 原生链路决定。
297
+ **Does Copilot Network Retry replace OpenCode's retry logic?**
298
+ No. The plugin keeps retry policy inside OpenCode by normalizing retryable Copilot network/TLS failures into a shape that OpenCode already recognizes as retryable.
308
299
 
309
300
  ---
310
301
 
@@ -1,6 +1,41 @@
1
- type FetchLike = (request: Request | URL | string, init?: RequestInit) => Promise<Response>;
2
- export declare function isRetryableCopilotFetchError(error: unknown): boolean;
3
- export declare function createCopilotRetryingFetch(baseFetch: FetchLike, options?: {
1
+ export type FetchLike = (request: Request | URL | string, init?: RequestInit) => Promise<Response>;
2
+ type JsonRecord = Record<string, unknown>;
3
+ export type CopilotRetryContext = {
4
+ client?: {
5
+ session?: {
6
+ messages?: (input: {
7
+ path: {
8
+ id: string;
9
+ };
10
+ }) => Promise<{
11
+ data?: Array<{
12
+ info?: {
13
+ id?: string;
14
+ role?: string;
15
+ };
16
+ parts?: Array<JsonRecord>;
17
+ }>;
18
+ }>;
19
+ message?: (input: {
20
+ path: {
21
+ id: string;
22
+ messageID: string;
23
+ };
24
+ }) => Promise<{
25
+ data?: {
26
+ parts?: Array<JsonRecord>;
27
+ };
28
+ }>;
29
+ };
30
+ };
31
+ directory?: string;
32
+ serverUrl?: URL;
4
33
  wait?: (ms: number) => Promise<void>;
5
- }): (request: Request | URL | string, init?: RequestInit) => Promise<Response>;
34
+ patchPart?: (request: {
35
+ url: string;
36
+ init: RequestInit;
37
+ }) => Promise<unknown>;
38
+ };
39
+ export declare function isRetryableCopilotFetchError(error: unknown): boolean;
40
+ export declare function createCopilotRetryingFetch(baseFetch: FetchLike, options?: CopilotRetryContext): (request: Request | URL | string, init?: RequestInit) => Promise<Response>;
6
41
  export {};