opencode-magpie-plugin 0.3.0 → 0.3.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/README.md CHANGED
@@ -55,7 +55,7 @@ OpenCode V2
55
55
 
56
56
  ```jsonc
57
57
  {
58
- "plugins": ["opencode-magpie-plugin@0.3.0"]
58
+ "plugins": ["opencode-magpie-plugin@0.3.1"]
59
59
  }
60
60
  ```
61
61
 
@@ -81,6 +81,8 @@ opencode service restart
81
81
 
82
82
  示例模型仅说明格式,实际列表取决于 Magpie 当前账号与配置。Magpie 自定义 provider ID 会原样映射为带 `magpie-` 前缀的 ID。
83
83
 
84
+ 网关中嵌套的远程来源按内层服务独立分组,例如 `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
+
84
86
  Routing group(例如 `group/auto`)会跨多个服务路由,因此不按 `owned_by` 或首个候选服务拆成 provider。没有插件 options 时,它们统一归到 **Magpie** 分组下。发送时仍保留网关原始 id(`group/auto`),价格只用 Magpie 给出的价格,不按成员猜测。
85
87
 
86
88
  ### 目录呈现
package/dist/index.mjs CHANGED
@@ -313,6 +313,23 @@ const providerName = (model) => {
313
313
  workbuddy: "WorkBuddy"
314
314
  }[model.owned_by] ?? model.owned_by;
315
315
  };
316
+ const nestedProvider = (row) => {
317
+ const prefix = `${row.owned_by}/`;
318
+ if (!row.id.startsWith(prefix)) return;
319
+ const remainder = row.id.slice(prefix.length);
320
+ const slash = remainder.indexOf("/");
321
+ if (slash <= 0 || slash === remainder.length - 1) return;
322
+ const source = remainder.slice(0, slash);
323
+ const label = providerName(row);
324
+ const sourceName = source === "auto" || source === "group" ? "routing group" : providerName({
325
+ id: source,
326
+ owned_by: source
327
+ });
328
+ return {
329
+ id: `${row.owned_by}/${source}`,
330
+ name: row.magpie_label?.split(" · ").length === 3 ? label : `${sourceName} · ${label}`
331
+ };
332
+ };
316
333
  /** Magpie writes context windows as `Claude Opus 5.5 @ 1m`. The picker shows `@1m`. */
317
334
  const displayName = (name) => name.replace(/@\s+(\d+(?:k|m))/gi, "@$1");
318
335
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -399,7 +416,8 @@ const buildInventory = (rows, baseURL, options = {}) => {
399
416
  const groupKey = routingGroupKey(row.id);
400
417
  const group = groupKey !== void 0;
401
418
  const bucket = groupKey ? buckets.find((entry$1) => groupKey.length > entry$1.prefix.length && groupKey.startsWith(entry$1.prefix)) : void 0;
402
- const owner = group ? bucket?.id ?? ROUTING_GROUP : row.owned_by;
419
+ const nested = group ? void 0 : nestedProvider(row);
420
+ const owner = group ? bucket?.id ?? ROUTING_GROUP : nested?.id ?? row.owned_by;
403
421
  const providerID = `magpie-${encodeURIComponent(owner)}`;
404
422
  const modelID = bucket && groupKey ? groupKey.slice(bucket.prefix.length) : groupKey ?? row.id.slice(row.id.indexOf("/") + 1);
405
423
  const { cost } = modelCost(row, group, options.catalog);
@@ -427,7 +445,7 @@ const buildInventory = (rows, baseURL, options = {}) => {
427
445
  const entry = providers.get(providerID) ?? {
428
446
  info: {
429
447
  id: providerID,
430
- name: bucket ? bucket.name : group ? "Magpie" : providerName(row),
448
+ name: bucket ? bucket.name : group ? "Magpie" : nested?.name ?? providerName(row),
431
449
  activation: "enabled",
432
450
  package: "@opencode/ai/providers/openai-compatible",
433
451
  settings: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-magpie-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Discover Magpie providers and models in OpenCode V2 with built-in pricing and automatic local gateway startup",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",