opencode-magpie-plugin 0.4.1 → 0.5.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/README.md +20 -6
- package/dist/index.mjs +16 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,19 +77,24 @@ opencode service restart
|
|
|
77
77
|
| --- | --- | --- | --- |
|
|
78
78
|
| Cursor | `magpie-cursor` | `magpie-cursor/gpt-5.5` | `cursor/gpt-5.5` |
|
|
79
79
|
| WorkBuddy | `magpie-workbuddy` | `magpie-workbuddy/claude-opus-4-6` | `workbuddy/claude-opus-4-6` |
|
|
80
|
-
| Magpie | `magpie-
|
|
80
|
+
| Magpie Group | `magpie-group` | `magpie-group/auto` | `group/auto` |
|
|
81
|
+
| Magpie Auto | `magpie-auto` | `magpie-auto/auto-glm-5.2` | `auto/glm-5.2` |
|
|
82
|
+
| Group · Remote Magpie | `magpie-remote-magpie%2Fgroup` | `magpie-remote-magpie%2Fgroup/group/auto` | `remote-magpie/group/auto` |
|
|
83
|
+
| Auto · Remote Magpie | `magpie-remote-magpie%2Fauto` | `magpie-remote-magpie%2Fauto/auto/glm-5.2` | `remote-magpie/auto/glm-5.2` |
|
|
81
84
|
|
|
82
85
|
示例模型仅说明格式,实际列表取决于 Magpie 当前账号与配置。Magpie 自定义 provider ID 会原样映射为带 `magpie-` 前缀的 ID。
|
|
83
86
|
|
|
84
|
-
网关中嵌套的远程来源按内层服务独立分组,例如 `remote-magpie/cursor/gpt-5.6-terra@272k` 显示在 **Cursor · Remote
|
|
87
|
+
网关中嵌套的远程来源按内层服务独立分组,例如 `remote-magpie/cursor/gpt-5.6-terra@272k` 显示在 **Cursor · Remote Magpie** 下,WorkBuddy、Codex、Astra 等各自分组,不再由首条模型的标签决定整个 remote 的名称。该示例的 provider ID 为 `magpie-remote-magpie%2Fcursor`,模型 ID 为 `cursor/gpt-5.6-terra@272k`,请求仍发送完整的 `remote-magpie/cursor/gpt-5.6-terra@272k`。从旧版本升级后,原先选在合并 remote 分组中的模型需要重新选择。
|
|
85
88
|
|
|
86
|
-
Routing group(例如 `group/auto`)会跨多个服务路由,因此不按 `owned_by` 或首个候选服务拆成 provider
|
|
89
|
+
Routing group(例如 `group/auto`)会跨多个服务路由,因此不按 `owned_by` 或首个候选服务拆成 provider。本地 `group/` 与 `auto/` 分别归到 **Magpie Group**、**Magpie Auto**;远程嵌套的 `remote-magpie/group/` 与 `remote-magpie/auto/` 分别显示为 **Group · Remote Magpie**、**Auto · Remote Magpie**。默认路由组的 provider 名称只出现一次 Magpie,不再把 Group 和 Auto 显示成同名分组。远端未给模型标签时也遵循这一规则。发送时仍保留网关原始 id,价格只用 Magpie 给出的价格,不按成员猜测。
|
|
90
|
+
|
|
91
|
+
本地默认路由组的 provider ID 从 `magpie-magpie` 拆为 `magpie-group` 与 `magpie-auto`,旧模型选择需要重新选择,`options.order` 的 key 也需对应更新。选择器中的模型 ID 和发给网关的 ID 不变;远程嵌套来源与自定义分桶的 provider ID 不变。
|
|
87
92
|
|
|
88
93
|
### 目录呈现
|
|
89
94
|
|
|
90
|
-
新版 Auto Group 的 `auto/<model>` 也按路由组处理,默认放在 `magpie-
|
|
95
|
+
新版 Auto Group 的 `auto/<model>` 也按路由组处理,默认放在 `magpie-auto`(Magpie Auto),选择器 ID 为 `auto-<model>`,请求仍发送原始 `auto/<model>`。它按 `auto-<model>` 匹配下述 `groups.prefix`,因此可用 `auto-` 单独分桶;模型名中的点号保持原样。旧的 `group/` 格式继续支持,默认放在 `magpie-group`(Magpie Group),普通厂商模型不会被自动组覆盖。自动组及其 Fast 变体仅采用 Magpie 报价。
|
|
91
96
|
|
|
92
|
-
路由组的成员由 Magpie 维护;这个插件只决定 OpenCode 选择器里怎么摆。分组、显示名和排序写在 `opencode.jsonc` 的插件 `options` 里,升级插件包之后仍在,不用再改 `dist`。空 options
|
|
97
|
+
路由组的成员由 Magpie 维护;这个插件只决定 OpenCode 选择器里怎么摆。分组、显示名和排序写在 `opencode.jsonc` 的插件 `options` 里,升级插件包之后仍在,不用再改 `dist`。空 options(或仍用字符串引用插件)和不声明时完全一样:`group/` 行都在 `magpie-group`,`auto/` 行都在 `magpie-auto`。
|
|
93
98
|
|
|
94
99
|
```jsonc
|
|
95
100
|
{
|
|
@@ -113,7 +118,7 @@ Routing group(例如 `group/auto`)会跨多个服务路由,因此不按 `o
|
|
|
113
118
|
|
|
114
119
|
上面只是写法示例,不是插件默认值。语义:
|
|
115
120
|
|
|
116
|
-
- 只对 id 以 `group/` 或 `auto/` 开头的行分桶。`groups` 按 `prefix` 最长优先匹配。命中后 provider 是 `magpie-<id>`,显示名是 `name`,选择器里的模型 id 去掉这段 prefix(`group/adams-deepseek-v4.1-flash` → `magpie-adams/deepseek-v4.1-flash`)。发给 Magpie 的仍是原始 id
|
|
121
|
+
- 只对 id 以 `group/` 或 `auto/` 开头的行分桶。`groups` 按 `prefix` 最长优先匹配。命中后 provider 是 `magpie-<id>`,显示名是 `name`,选择器里的模型 id 去掉这段 prefix(`group/adams-deepseek-v4.1-flash` → `magpie-adams/deepseek-v4.1-flash`)。发给 Magpie 的仍是原始 id。没匹配到的组分别回到 `magpie-group`(Magpie Group)或 `magpie-auto`(Magpie Auto),保留各自默认的选择器模型 ID。厂商模型(`cursor/`、`workbuddy/`)不受 `groups` 影响。
|
|
117
122
|
- OpenCode 同 provider 内按 `time.released` 倒序排。`order` 的 key 是最终 provider id,值是最终模型 id(已去前缀),越靠前越靠前。名单里没有的保持 0,退化为字母序。`-fast` 克隆继承父模型的权重并紧跟在后面;不要给它单独写一条,除非那个 `-fast` id 自己出现在 `order` 里。provider 之间的顺序控制不了。
|
|
118
123
|
- 插件不隐藏模型。网关列出的都会出现,没标价的也一样。不想在 OpenCode 里看到某个组,在 Magpie 里处理:不用了就 `magpie group rm <id>`,只对 OpenCode 收窄就用 `magpie visible opencode …`。组的成员是厂商模型时,删掉一个组不会影响把同一批模型当成员的其他组。
|
|
119
124
|
|
|
@@ -223,6 +228,15 @@ MAGPIE_ADDR=127.0.0.1:3426 opencode --standalone
|
|
|
223
228
|
|
|
224
229
|
models.dev 缓存写入 `$XDG_CACHE_HOME/opencode-magpie-plugin/models.json`(默认 `~/.cache/opencode-magpie-plugin/models.json`)。首次可只读复用 Magpie、OpenCode 的 `models.json`;下载只写插件自己的目录。每次模型刷新检查缓存,超过 24 小时后台更新,缺价时可提前到 6 小时;同进程下载去重且失败后至少间隔 6 小时重试。首次下载和更新不阻塞模型发现,成功后下一次 30 秒刷新采用新目录;离线保留旧缓存。下载源为 `https://models.dev/api.json`,仍然零运行时依赖,基础价和 context 阶梯价一并传给 OpenCode。
|
|
225
230
|
|
|
231
|
+
### 0.5.0
|
|
232
|
+
|
|
233
|
+
- 本地默认路由组拆为 Magpie Group(`magpie-group`)与 Magpie Auto(`magpie-auto`);旧 `magpie-magpie` 下的模型需重新选择,排序配置需更新 provider ID。
|
|
234
|
+
- 远程嵌套路由组分别显示为 Group · Remote Magpie、Auto · Remote Magpie,provider 名称只出现一次 Magpie,并统一远程来源名的大小写。远程 provider ID、原始请求 ID、计价与 Fast 行为不变。
|
|
235
|
+
|
|
236
|
+
### 0.4.2
|
|
237
|
+
|
|
238
|
+
- 修正远端网关下路由组(`auto` / `group`)的 provider 显示名:不再显示为 "routing group",改为 "Magpie"。
|
|
239
|
+
|
|
226
240
|
### 0.4.1
|
|
227
241
|
|
|
228
242
|
- 生图 skill 增加回退规则:某模型不可用(额度、积分、不支持的尺寸等)时不重试原模型,改用 `image_list` 中其他模型(优先换 provider),最多尝试三个模型。
|
package/dist/index.mjs
CHANGED
|
@@ -277,8 +277,8 @@ const priceInProvider = (catalog, maker, id) => {
|
|
|
277
277
|
//#region src/catalog.ts
|
|
278
278
|
/** Whether any model Magpie lists has no price in any source, which asks for a fresher catalog. */
|
|
279
279
|
const hasUnpricedModel = (inventory) => inventory.some((entry) => entry.models.some((model) => model.cost.length === 0));
|
|
280
|
-
/** Routing groups
|
|
281
|
-
const
|
|
280
|
+
/** Routing groups are named by their own source rather than by a member vendor. */
|
|
281
|
+
const routingGroupName = (source) => source === "group" ? "Group" : source === "auto" ? "Auto" : void 0;
|
|
282
282
|
const routingGroupKey = (id) => {
|
|
283
283
|
if (id.startsWith("group/")) return id.slice(6);
|
|
284
284
|
if (id.startsWith("auto/")) return `auto-${id.slice(5)}`;
|
|
@@ -306,13 +306,13 @@ const pricingProvider = (owner) => {
|
|
|
306
306
|
"kalm"
|
|
307
307
|
].find((provider) => provider === id);
|
|
308
308
|
};
|
|
309
|
+
const normalizeProviderName = (name) => name.replace(/\bremote[- ]magpie\b/gi, "Remote Magpie");
|
|
309
310
|
const providerName = (model) => {
|
|
310
311
|
const label = model.magpie_label?.split(" · ").slice(1).join(" · ");
|
|
311
|
-
|
|
312
|
-
return {
|
|
312
|
+
return normalizeProviderName(label || ({
|
|
313
313
|
cursor: "Cursor",
|
|
314
314
|
workbuddy: "WorkBuddy"
|
|
315
|
-
}[model.owned_by] ?? model.owned_by;
|
|
315
|
+
}[model.owned_by] ?? model.owned_by));
|
|
316
316
|
};
|
|
317
317
|
const nestedProvider = (row) => {
|
|
318
318
|
const prefix = `${row.owned_by}/`;
|
|
@@ -321,14 +321,20 @@ const nestedProvider = (row) => {
|
|
|
321
321
|
const slash = remainder.indexOf("/");
|
|
322
322
|
if (slash <= 0 || slash === remainder.length - 1) return;
|
|
323
323
|
const source = remainder.slice(0, slash);
|
|
324
|
+
const routing = routingGroupName(source);
|
|
325
|
+
const parts = row.magpie_label?.split(" · ") ?? [];
|
|
326
|
+
if (routing) return {
|
|
327
|
+
id: `${row.owned_by}/${source}`,
|
|
328
|
+
name: `${routing} · ${normalizeProviderName(parts.length === 3 ? parts[2] : providerName(row))}`
|
|
329
|
+
};
|
|
324
330
|
const label = providerName(row);
|
|
325
|
-
const sourceName =
|
|
331
|
+
const sourceName = providerName({
|
|
326
332
|
id: source,
|
|
327
333
|
owned_by: source
|
|
328
334
|
});
|
|
329
335
|
return {
|
|
330
336
|
id: `${row.owned_by}/${source}`,
|
|
331
|
-
name:
|
|
337
|
+
name: parts.length === 3 ? label : `${sourceName} · ${label}`
|
|
332
338
|
};
|
|
333
339
|
};
|
|
334
340
|
/** Magpie writes context windows as `Claude Opus 5.5 @ 1m`. The picker shows `@1m`. */
|
|
@@ -414,11 +420,12 @@ const buildInventory = (rows, baseURL, options = {}) => {
|
|
|
414
420
|
const buckets = [...presentation.groups].sort((left, right) => right.prefix.length - left.prefix.length);
|
|
415
421
|
for (const row of rows) if (row.service_tiers?.some((tier) => (typeof tier === "string" ? tier : tier.id) === "priority")) fastModelIDs.add(row.id);
|
|
416
422
|
rows.filter((row) => !row.kind && row.id.includes("/")).forEach((row) => {
|
|
423
|
+
const source = row.id.slice(0, row.id.indexOf("/"));
|
|
417
424
|
const groupKey = routingGroupKey(row.id);
|
|
418
425
|
const group = groupKey !== void 0;
|
|
419
426
|
const bucket = groupKey ? buckets.find((entry$1) => groupKey.length > entry$1.prefix.length && groupKey.startsWith(entry$1.prefix)) : void 0;
|
|
420
427
|
const nested = group ? void 0 : nestedProvider(row);
|
|
421
|
-
const owner = group ? bucket?.id ??
|
|
428
|
+
const owner = group ? bucket?.id ?? source : nested?.id ?? row.owned_by;
|
|
422
429
|
const providerID = `magpie-${encodeURIComponent(owner)}`;
|
|
423
430
|
const modelID = bucket && groupKey ? groupKey.slice(bucket.prefix.length) : groupKey ?? row.id.slice(row.id.indexOf("/") + 1);
|
|
424
431
|
const { cost } = modelCost(row, group, options.catalog);
|
|
@@ -446,7 +453,7 @@ const buildInventory = (rows, baseURL, options = {}) => {
|
|
|
446
453
|
const entry = providers.get(providerID) ?? {
|
|
447
454
|
info: {
|
|
448
455
|
id: providerID,
|
|
449
|
-
name: bucket ? bucket.name : group ?
|
|
456
|
+
name: bucket ? bucket.name : group ? `Magpie ${routingGroupName(source)}` : nested?.name ?? providerName(row),
|
|
450
457
|
activation: "enabled",
|
|
451
458
|
package: "@opencode/ai/providers/openai-compatible",
|
|
452
459
|
settings: {
|
package/package.json
CHANGED