opencode-copilot-auto 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2 (2026-11-22)
4
+
5
+ - README: the install example used `"plugin"`; OpenCode 2.x reads `"plugins"`.
6
+
7
+ ## 0.1.1 (2026-11-22)
8
+
9
+ - 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".
10
+
3
11
  ## 0.1.0 (2026-11-22)
4
12
 
5
13
  - Makes GitHub Copilot Free work in OpenCode 2.x by routing requests through Copilot's Auto mode.
6
14
  - 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.
15
+ - 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 one GitHub Copilot entry in the model picker, **Auto (Copilot picks the model)**,
23
- because Auto decides which model answers whatever you pick, and
24
- - routes requests for it (and any other model your account allows) through Auto: it asks Copilot which model to
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.
@@ -36,11 +37,11 @@ Copilot login and identify themselves as `opencode-copilot-auto`.
36
37
  2. Add the plugin to `opencode.json`:
37
38
 
38
39
  ```json
39
- { "plugin": ["opencode-copilot-auto@0.1.0"] }
40
+ { "plugins": ["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 **Auto (Copilot picks the model)** under GitHub Copilot.
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 one entry in the model picker, "Auto (Copilot picks the model)",
13
- // since Auto decides which model answers whatever is picked,
14
- // - when it (or any model the account allows) is used, asks Auto which model
15
- // to run and routes the request there with Auto's session token.
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.0"
25
+ export const VERSION = "0.1.2"
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 AUTO_NAME = "Auto (Copilot picks the model)"
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 show the Auto entry.
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
- // One picker entry: picking a specific model would be ignored by Auto anyway.
207
- // It stands on the first allowed model; the others are hidden.
208
- const [entry, ...rest] = [...account.models].filter((id) => models.get(PROVIDER, id))
209
- if (!entry) return
210
- models.update(PROVIDER, entry, (m) => { m.enabled = true; m.name = AUTO_NAME })
211
- for (const id of rest) models.update(PROVIDER, id, (m) => { m.enabled = false })
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-copilot-auto",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "OpenCode plugin that makes GitHub Copilot Free work by routing requests through Copilot's Auto mode",
5
5
  "type": "module",
6
6
  "main": "index.js",