opencode-copilot-auto 0.1.0 → 0.1.1
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/CHANGELOG.md +5 -1
- package/README.md +5 -4
- package/index.js +19 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1 (2026-11-22)
|
|
4
|
+
|
|
5
|
+
- Fixes 0.1.0 hiding the models Auto routes to. OpenCode refuses a hidden model, so a request failed whenever Auto picked a model other than the picker's one entry. All allowed models stay on again, each labelled "· via Auto".
|
|
6
|
+
|
|
3
7
|
## 0.1.0 (2026-11-22)
|
|
4
8
|
|
|
5
9
|
- Makes GitHub Copilot Free work in OpenCode 2.x by routing requests through Copilot's Auto mode.
|
|
6
10
|
- Turns on only for accounts OpenCode can't serve by itself, and follows login changes within 30 seconds.
|
|
7
|
-
- Shows one picker entry, "Auto (Copilot picks the model)", since Auto decides which model answers.
|
|
11
|
+
- Shows one picker entry, "Auto (Copilot picks the model)", since Auto decides which model answers. (This broke routing; fixed in 0.1.1.)
|
package/README.md
CHANGED
|
@@ -19,9 +19,10 @@ It turns on only when OpenCode can't serve your account by itself: GitHub marks
|
|
|
19
19
|
none of your models as pickable and none has an Auto discount. That's Copilot
|
|
20
20
|
Free today; the check doesn't rely on plan names. It then:
|
|
21
21
|
|
|
22
|
-
- shows
|
|
23
|
-
because Auto decides which model answers whatever you
|
|
24
|
-
|
|
22
|
+
- shows the chat models GitHub allows your account in the model picker, each
|
|
23
|
+
labelled **· via Auto**, because Auto decides which model answers whatever you
|
|
24
|
+
pick, and
|
|
25
|
+
- routes requests for those models through Auto: it asks Copilot which model to
|
|
25
26
|
use, switches the request to it, and adds Auto's session token. Auto keeps its
|
|
26
27
|
pick for the session until the token is about to expire, or until the session
|
|
27
28
|
is compacted.
|
|
@@ -40,7 +41,7 @@ Copilot login and identify themselves as `opencode-copilot-auto`.
|
|
|
40
41
|
```
|
|
41
42
|
|
|
42
43
|
or copy `index.js` to `~/.config/opencode/plugins/copilot-auto.js`.
|
|
43
|
-
3. Restart OpenCode and pick
|
|
44
|
+
3. Restart OpenCode and pick any GitHub Copilot model marked **· via Auto**.
|
|
44
45
|
|
|
45
46
|
The model that actually answered is shown under each reply.
|
|
46
47
|
|
package/index.js
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
// It turns on only when OpenCode can't serve the account by itself: GitHub marks
|
|
10
10
|
// none of the account's models as pickable and none has an Auto discount. That is
|
|
11
11
|
// Copilot Free today. It then:
|
|
12
|
-
// - shows
|
|
13
|
-
// since Auto decides which model answers
|
|
14
|
-
//
|
|
15
|
-
//
|
|
12
|
+
// - shows the chat models GitHub allows the account in the model picker,
|
|
13
|
+
// each labelled "· via Auto", since Auto decides which model answers
|
|
14
|
+
// whatever is picked. They all stay switched on: OpenCode refuses to run a
|
|
15
|
+
// hidden model, and Auto may pick any of them.
|
|
16
|
+
// - when one is used, asks Auto which model to run and routes the request
|
|
17
|
+
// there with Auto's session token.
|
|
16
18
|
// On any other account it does nothing, so OpenCode's own Copilot support is untouched.
|
|
17
19
|
//
|
|
18
20
|
// Set OPENCODE_COPILOT_AUTO=off to turn it off, or =always to route through Auto
|
|
@@ -20,7 +22,7 @@
|
|
|
20
22
|
|
|
21
23
|
import { createHash } from "node:crypto"
|
|
22
24
|
|
|
23
|
-
export const VERSION = "0.1.
|
|
25
|
+
export const VERSION = "0.1.1"
|
|
24
26
|
const PROVIDER = "github-copilot"
|
|
25
27
|
const USER_AGENT = `opencode-copilot-auto/${VERSION}`
|
|
26
28
|
const API_VERSION = "2026-08-01" // what OpenCode 2.3 sends to the Copilot API
|
|
@@ -33,7 +35,7 @@ const DEFAULT_ROUTE_MS = 20 * 60 * 1000 // when Auto gives no expiry
|
|
|
33
35
|
const TIMEOUT_MS = 15 * 1000
|
|
34
36
|
const MAX_SESSIONS = 200
|
|
35
37
|
const MAX_PROMPT_CHARS = 2000
|
|
36
|
-
const
|
|
38
|
+
const VIA_AUTO = " · via Auto"
|
|
37
39
|
|
|
38
40
|
// ---------- reading OpenCode's Copilot login ----------
|
|
39
41
|
|
|
@@ -192,7 +194,7 @@ export function createPlugin(deps = {}) {
|
|
|
192
194
|
async setup(ctx) {
|
|
193
195
|
if (mode === "off") return
|
|
194
196
|
// Check the account now. OpenCode may have built its model list already,
|
|
195
|
-
// so rebuild it once the allowed models are known, to
|
|
197
|
+
// so rebuild it once the allowed models are known, to unhide them.
|
|
196
198
|
getAccount(ctx).then((acct) => {
|
|
197
199
|
if (!active(acct) || !acct.models.size || typeof ctx.model?.reload !== "function") return
|
|
198
200
|
try {
|
|
@@ -203,12 +205,16 @@ export function createPlugin(deps = {}) {
|
|
|
203
205
|
if (typeof ctx.model?.transform === "function") {
|
|
204
206
|
await ctx.model.transform((models) => {
|
|
205
207
|
if (!account || !active(account) || account.key !== login?.key) return
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
// Every allowed model stays on: Auto may route to any of them, and OpenCode
|
|
209
|
+
// refuses a hidden one. The label says Auto decides, whatever is picked.
|
|
210
|
+
for (const id of account.models) {
|
|
211
|
+
if (!models.get(PROVIDER, id)) continue
|
|
212
|
+
models.update(PROVIDER, id, (m) => {
|
|
213
|
+
m.enabled = true
|
|
214
|
+
const name = typeof m.name === "string" && m.name ? m.name : id
|
|
215
|
+
if (!name.endsWith(VIA_AUTO)) m.name = name + VIA_AUTO
|
|
216
|
+
})
|
|
217
|
+
}
|
|
212
218
|
})
|
|
213
219
|
}
|
|
214
220
|
|
package/package.json
CHANGED