@nimoxie/dsh-model-organizer 0.3.4 → 0.3.5

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/DEVELOPING.md CHANGED
@@ -50,6 +50,7 @@ ctx.inject(["slots", "settingsScope", "remote", "remote.settings"], (s) => mount
50
50
  ## 写 UI 时踩过的坑
51
51
 
52
52
  - **primitives 的新组件(MenuSurface/Input/StateDot 等)是 `React.forwardRef` 包装的——是对象不是函数**。`typeof X === "function"` 永远为 false,所有这类门控静默失败、全部走降级路径(本插件因此丢过 MenuSurface 的磨砂和整个搜索框)。组件判定用 `isComponent`:函数,或带 `.render` 函数的对象。`rankByName` 这类工具函数才是真函数。
53
+ - **图标名要用 primitives 实际导出的名字**:只有 `IconXxxOutlineRegular` / `IconXxxOutlineMedium` / `IconXxxFillRegular` 这类后缀,**没有 `IconXxxOutline16`/`14` 尺寸数字名**。猜错名字 `icon()` 静默返回 null——本插件的勾、分组箭头因此从第一版起就没渲染过,靠触发器的文字兜底掩盖至今。发新图标前先 grep 导出表。
53
54
 
54
55
  - **边框必须用 longhand**(`borderWidth/borderStyle/borderColor`)。用 shorthand `border` 再叠加 `borderColor` 时 React 会展开 shorthand;回退时移除 `borderColor`,`border-color` 落回 `currentColor` → "拖拽结束后高亮边框一直不消失"。
55
56
  - **拖拽会把源行留在焦点上**:行加 `tabIndex:-1`,drop/dragend 时 `blur()`;并且不要给行画 `:focus-visible` 背景(官方 `option` 类自带一条 → "拖完还留一块灰底")。
@@ -70,3 +71,5 @@ npm publish
70
71
  发布需要带 **Bypass 2FA** 的 Granular Access Token(npm 2025-11 起只支持 granular token):npmjs.com → 头像 → Access Tokens → Generate New Token → Packages 选 **All Packages + Read and write (publish and stage)**、**Organizations 选 No access**、勾 **Bypass two-factor authentication**;然后 `npm config set //registry.npmjs.org/:_authToken=npm_xxx`(写进用户级 `.npmrc`,不要放进仓库)。
71
72
 
72
73
  包是 scoped 名(`@nimoxie/dsh-model-organizer`,用户作用域),`publishConfig.access: "public"` 已写进 package.json,`npm publish` 不用再带参数。老的无作用域名 `dsh-model-organizer` 已停更,记得发一次 `npm deprecate dsh-model-organizer "已迁移到 @nimoxie/dsh-model-organizer"` 留路标。
74
+
75
+ **改包名是牵一发动全身的**——包名是宿主解析插件的文件系统坐标,不止 package.json:`cordis.patch.yml` 的 `insert.name`(按包名从 node_modules 找插件,找不到则插件整体不加载)、`lib/client.js` 的 `__ModuleLoader__.load({ id })`(模块 id 必须等于包名,否则 bundle 二次执行时被判定为重复抢注,boot 直接失败)。localStorage 键和 locale 命名空间是纯数据键,刻意不改(改了丢用户排序数据)。
package/README.md CHANGED
@@ -4,19 +4,19 @@
4
4
 
5
5
  ## 它解决什么问题
6
6
 
7
- 官方那个模型下拉是一个扁平长列表——供应商只是粘性小标题,模型多的时候要滚很久,也没法按自己的习惯排序。这个插件把它改成两级:**先看供应商,点开才看模型**,并且供应商和模型的顺序都能直接拖。
7
+ 官方那个模型下拉是一个扁平长列表——供应商只是粘性小标题,模型多的时候要滚很久,也没法按自己的习惯排序。这个插件把它改成两级:**根层先选「模型」或「推理等级」,模型层里按供应商分组**,供应商和模型的顺序都能直接拖。
8
8
 
9
9
  ## 功能
10
10
 
11
11
  **输入框的模型菜单**
12
- - 根层与官方一致:「模型」「推理等级」两个入口(推理等级只在模型声明了等级时出现,怎么声明见下文)
12
+ - 根层与官方一致:「模型」「推理等级」两个入口——「推理等级」**常驻**,未配置等级的模型上置灰、不可点
13
13
  - 「模型」里保留本插件的改进:按供应商分组、可折叠,顺序与设置页浮窗一致,当前模型打 ✓
14
14
  - 模型多于 4 个时,「模型」层顶部有官方同款的「搜索模型」框(0.2.0-rc.2 起官方才有此样式,旧版自动隐藏)
15
15
  - 外观完全沿用官方样式(同一个菜单表面、同一套图标,含官方的毛玻璃背景)
16
16
 
17
17
  **排序**
18
18
  - 在「设置 → 模型」右下角的浮窗里,**直接拖动**供应商行或模型行
19
- - 模型顺序保存到 DSH 的 `settings.yaml`:换浏览器、清缓存都不丢,所有打开这份 DSH 的设备共用;供应商顺序只记在当前浏览器里
19
+ - 模型顺序通过官方设置接口持久化(跟着 DSH 的配置走,不存浏览器);供应商顺序只记在当前浏览器里
20
20
 
21
21
  ## 安装
22
22
 
@@ -37,20 +37,16 @@ dsh plugin --profile web add github:NimoXie15/dsh-model-organizer
37
37
  dsh plugin --profile web add link:/absolute/path/to/dsh-model-organizer
38
38
  ```
39
39
 
40
- > **兼容性**:已在 DSH `0.1.7`、`0.2.0-rc.1` 上核验,`0.1.5` 起都可用(0.1.7 调整了一处内部接口,本插件已做兼容处理)。注意 0.2.0 起官方主题把菜单背景改成了半透明,模型菜单也随之变通透——这是跟随官方新皮肤,不是故障。
40
+ > **兼容性**:已在 DSH `0.1.7`、`0.2.0-rc.1`(web)、`0.2.0-rc.2`(桌面端)上核验,`0.1.5` 起都可用。
41
41
  >
42
42
  > 升级插件后如果界面没变化,按 **Ctrl+Shift+R** 强刷一次(浏览器可能还在用缓存的旧版本)。
43
43
 
44
- ## 截图
44
+ ## 想让「推理等级」可用,需要模型自己声明
45
45
 
46
- 📷 待补充。
47
-
48
- ## 想让「推理等级」出现,需要模型自己声明
49
-
50
- 只有模型提供了等级,菜单里才会出现「推理等级」入口——这与官方行为一致。在你的 `settings.yaml` 里给模型加上:
46
+ 「推理等级」入口常驻菜单根层;只有模型声明了等级,它才可点、才会在按钮上显示当前等级。在模型配置里加上(`llm-pi-ai.providers.<供应商>.models[]`;0.2.x 在 profile 的 `cordis.patch.yml`,0.1.x 在 `settings.yaml`):
51
47
 
52
48
  ```yaml
53
- # settings.yaml → llm-pi-ai.providers.<供应商>.models[]
49
+ # llm-pi-ai.providers.<供应商>.models[](0.2.x 在 profile 的 cordis.patch.yml;0.1.x 在 settings.yaml)
54
50
  - id: <你的模型 ID>
55
51
  reasoningEfforts: # 键=菜单里显示的等级,值=选中时发给模型的 API 参数;只有 off 可以留空
56
52
  off:
@@ -60,7 +56,7 @@ dsh plugin --profile web add link:/absolute/path/to/dsh-model-organizer
60
56
  ## 已知限制
61
57
 
62
58
  - 排序浮窗只列「设置 → 模型」里自己添加的供应商,**DeepSeek 官方供应商不能排序**(输入框菜单里照常出现、可选)
63
- - 供应商顺序、浮窗位置只存在当前浏览器;模型顺序存在 `settings.yaml` 里,同一份 DSH 的所有设备共用——两台机器各装一份 DSH 则互不相通
59
+ - 供应商顺序、浮窗位置只存在当前浏览器;模型顺序存在 DSH 的用户配置里,同一份 DSH 的所有设备共用——两台机器各装一份 DSH 则互不相通
64
60
  - 不修改 DSH 本体,只通过官方提供的扩展点接入
65
61
 
66
62
  ## 许可
package/cordis.patch.yml CHANGED
@@ -1,6 +1,6 @@
1
- # dsh-model-organizer bundle patch: one host row over the web profile.
1
+ # @nimoxie/dsh-model-organizer bundle patch: one host row over the web profile.
2
2
  # The row name resolves from the profile's own node_modules where
3
3
  # `dsh plugin --profile web add <path>` installed this package.
4
4
  - insert:
5
5
  - id: model-organizer
6
- name: dsh-model-organizer
6
+ name: "@nimoxie/dsh-model-organizer"
package/lib/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  window.__ModuleLoader__.load({
2
- id: "dsh-model-organizer",
2
+ id: "@nimoxie/dsh-model-organizer",
3
3
  factory: (require) => {
4
4
  const module = { exports: {} };
5
5
  const exports = module.exports;
@@ -42,6 +42,7 @@ window.__ModuleLoader__.load({
42
42
  "composer.searchClear": "清除搜索",
43
43
  "composer.searchEmpty": "没有匹配的模型。",
44
44
  "composer.selectFailed": "选择失败:{msg}",
45
+ "composer.effortNone": "未配置",
45
46
  "composer.none": "未选择模型",
46
47
  "composer.empty": "暂无可用模型",
47
48
  "composer.locked": "当前不可切换模型",
@@ -51,7 +52,6 @@ window.__ModuleLoader__.load({
51
52
  "composer.effort": "推理等级",
52
53
  "composer.effortDefault": "Default",
53
54
  "composer.effortEmpty": "当前模型未提供推理等级。",
54
- "composer.effortBack": "模型",
55
55
  "composer.refreshing": "正在刷新模型列表…",
56
56
  "order.title": "模型顺序",
57
57
  "order.hint": "拖动 ⠿ 调整,松手即保存",
@@ -72,6 +72,7 @@ window.__ModuleLoader__.load({
72
72
  "composer.searchClear": "Clear search",
73
73
  "composer.searchEmpty": "No matching models.",
74
74
  "composer.selectFailed": "Selection failed: {msg}",
75
+ "composer.effortNone": "Not configured",
75
76
  "composer.none": "No model",
76
77
  "composer.empty": "No models available",
77
78
  "composer.locked": "Model switching unavailable",
@@ -81,7 +82,6 @@ window.__ModuleLoader__.load({
81
82
  "composer.effort": "Effort",
82
83
  "composer.effortDefault": "Default",
83
84
  "composer.effortEmpty": "This model provides no reasoning effort levels.",
84
- "composer.effortBack": "Model",
85
85
  "composer.refreshing": "Refreshing model list…",
86
86
  "order.title": "Model order",
87
87
  "order.hint": "Drag ⠿ to reorder, then save",
@@ -115,7 +115,7 @@ window.__ModuleLoader__.load({
115
115
  code changes, so a browser can keep running an old build until a hard reload.
116
116
  Kept OFF the UI (it is not user-facing): read it as
117
117
  `window.__dshModelOrganizerBuild` when a stale build is suspected. */
118
- const BUILD = "b29";
118
+ const BUILD = "b33";
119
119
 
120
120
  let officialClasses = null;
121
121
  let officialClassesSheets = -1;
@@ -232,6 +232,11 @@ window.__ModuleLoader__.load({
232
232
  /* (the header's own arrow button is gone — the row toggles on click) */
233
233
 
234
234
  ".dsh-mo-model{padding-left:28px;position:relative;}",
235
+ /* Permanent-but-unconfigured effort cell: caption tone (the search
236
+ placeholder's token — dimmed is unreadably faint), not-allowed
237
+ cursor, hover-proof (doubled selectors outrank the shipped rules). */
238
+ ".dsh-mo-cell-disabled,.dsh-mo-cell-disabled.dsh-mo-cell-disabled{color:var(--dsw-alias-label-caption);cursor:not-allowed;}",
239
+ ".dsh-mo-cell-disabled:hover,.dsh-mo-cell-disabled.dsh-mo-cell-disabled:hover{background:transparent;cursor:not-allowed;}",
235
240
  ".dsh-mo-model::before{content:'';position:absolute;left:15px;top:50%;width:5px;height:5px;margin-top:-2.5px;border-radius:50%;background:var(--dsw-alias-label-tertiary);opacity:.5;}",
236
241
  ".dsh-mo-model[aria-checked='true']::before{background:var(--dsw-alias-label-primary);opacity:.9;}"
237
242
  ];
@@ -240,6 +245,8 @@ window.__ModuleLoader__.load({
240
245
  aria-checked, so the drag lists are untouched. */
241
246
  if (C !== null) {
242
247
  rules.push("." + C.option + "[aria-checked='true'] ." + C.modelName + "{font-weight:600}");
248
+ /* cellValue paints its own color; fold it back to the dimmed cell's. */
249
+ rules.push(".dsh-mo-cell-disabled ." + C.cellValue + "{color:inherit;}");
243
250
  }
244
251
  style.textContent = rules.join("");
245
252
  } catch (e) {}
@@ -815,12 +822,12 @@ window.__ModuleLoader__.load({
815
822
  .split("{model}").join(label)
816
823
  .split("{effort}").join(effortLabel === undefined ? "" : effortLabel);
817
824
 
818
- const chevronIcon = icon("IconChevronDownOutline14", {
825
+ const chevronIcon = icon("IconChevronDownOutlineRegular", {
819
826
  className: C !== null ? cx(C.chevron, open && C.chevronOpen) : undefined,
820
827
  style: C === null ? S.caret : undefined
821
828
  });
822
829
  const triggerChildren = [];
823
- const triggerGlyph = icon("IconDataOutline16", { key: "g", className: C !== null ? C.triggerIcon : undefined, size: 16 });
830
+ const triggerGlyph = icon("IconDataOutlineRegular", { key: "g", className: C !== null ? C.triggerIcon : undefined, size: 16 });
824
831
  if (triggerGlyph !== null) triggerChildren.push(triggerGlyph);
825
832
  triggerChildren.push(h("span", { key: "l", className: C !== null ? C.triggerLabel : undefined, style: C === null ? S.chipLabel : undefined }, label));
826
833
  if (effortLabel !== undefined) {
@@ -892,7 +899,7 @@ window.__ModuleLoader__.load({
892
899
  h("span", { key: "n", className: C !== null ? C.cellLabel : undefined, style: C === null ? undefined : undefined }, group.name || group.id),
893
900
  h("span", { key: "v", className: C !== null ? C.cellValue : undefined, style: C === null ? S.groupCount : undefined }, group.models.length + " " + t("composer.count"))
894
901
  ];
895
- const groupChevron = icon("IconChevronRightOutline14", {
902
+ const groupChevron = icon("IconChevronRightOutlineRegular", {
896
903
  key: "i",
897
904
  className: C !== null ? cx(C.cellChevron, "dsh-mo-chev") : "dsh-mo-chev",
898
905
  style: C === null ? S.groupChevron : undefined
@@ -911,7 +918,7 @@ window.__ModuleLoader__.load({
911
918
 
912
919
  const items = !isOpen ? [] : group.models.map(function (model) {
913
920
  const selected = current !== null && current.provider === group.id && current.model === model.id;
914
- const check = selected ? icon("IconCheckOutline16", { key: "k" }) : null;
921
+ const check = selected ? icon("IconCheckOutlineRegular", { key: "k" }) : null;
915
922
  return h("button", {
916
923
  key: model.id,
917
924
  ref: itemRef(),
@@ -956,23 +963,26 @@ window.__ModuleLoader__.load({
956
963
  },
957
964
  h("span", { key: "l", className: C !== null ? C.cellLabel : undefined }, t("composer.menuModel")),
958
965
  h("span", { key: "v", className: C !== null ? C.cellValue : undefined }, label),
959
- icon("IconChevronRightOutline14", { key: "c", className: C !== null ? C.cellChevron : undefined })
966
+ icon("IconChevronRightOutlineRegular", { key: "c", className: C !== null ? C.cellChevron : undefined })
967
+ ));
968
+ /* The effort entry is PERMANENT (unlike the shipped conditional one):
969
+ models without declared levels render it dimmed, unclickable and
970
+ skipped by the keyboard walk, so the root pair never reflows. */
971
+ const effortEnabled = reasoning !== undefined;
972
+ paneChildren.push(h("button", {
973
+ key: "effort",
974
+ ref: itemRef(),
975
+ type: "button",
976
+ role: "menuitem",
977
+ className: C !== null ? cx(C.cell, !effortEnabled && "dsh-mo-cell-disabled") : undefined,
978
+ style: C === null ? S.fallbackGroupTitle : undefined,
979
+ disabled: !effortEnabled,
980
+ onClick: effortEnabled ? function () { setPane("effort"); } : undefined
981
+ },
982
+ h("span", { key: "l", className: C !== null ? C.cellLabel : undefined }, t("composer.effort")),
983
+ h("span", { key: "v", className: C !== null ? C.cellValue : undefined }, effortEnabled ? effortLabel : t("composer.effortNone")),
984
+ icon("IconChevronRightOutlineRegular", { key: "c", className: C !== null ? cx(C.cellChevron, !effortEnabled && "dsh-mo-cell-disabled") : undefined })
960
985
  ));
961
- if (reasoning !== undefined) {
962
- paneChildren.push(h("button", {
963
- key: "effort",
964
- ref: itemRef(),
965
- type: "button",
966
- role: "menuitem",
967
- className: C !== null ? C.cell : undefined,
968
- style: C === null ? S.fallbackGroupTitle : undefined,
969
- onClick: function () { setPane("effort"); }
970
- },
971
- h("span", { key: "l", className: C !== null ? C.cellLabel : undefined }, t("composer.effort")),
972
- h("span", { key: "v", className: C !== null ? C.cellValue : undefined }, effortLabel),
973
- icon("IconChevronRightOutline14", { key: "c", className: C !== null ? C.cellChevron : undefined })
974
- ));
975
- }
976
986
  } else if (pane === "effort") {
977
987
  if (effortChoices.length === 0) {
978
988
  paneChildren.push(h("div", { key: "ee", className: C !== null ? C.empty : undefined, style: C === null ? S.menuEmpty : undefined }, t("composer.effortEmpty")));
@@ -983,7 +993,7 @@ window.__ModuleLoader__.load({
983
993
  style: C === null ? S.fallbackGroups : undefined
984
994
  }, effortChoices.map(function (level) {
985
995
  const selected = effectiveEffort === level.effort;
986
- const check = selected ? icon("IconCheckOutline16", { key: "k" }) : null;
996
+ const check = selected ? icon("IconCheckOutlineRegular", { key: "k" }) : null;
987
997
  return h("button", {
988
998
  key: level.key,
989
999
  ref: itemRef(),
@@ -1221,7 +1231,7 @@ window.__ModuleLoader__.load({
1221
1231
  if (note === "ok") notes.push(h("span", { key: "ok", style: S.ok }, t("order.saved")));
1222
1232
  else if (note !== null) notes.push(h("span", { key: "n", style: S.dirty }, note));
1223
1233
  for (let i = 0; i < notes.length; i++) headChildren.push(notes[i]);
1224
- const headChevron = icon("IconChevronRightOutline14", {
1234
+ const headChevron = icon("IconChevronRightOutlineRegular", {
1225
1235
  key: "c",
1226
1236
  className: C !== null ? cx(C.cellChevron, "dsh-mo-chev") : "dsh-mo-chev",
1227
1237
  style: C === null ? S.groupChevron : undefined
@@ -1292,7 +1302,6 @@ window.__ModuleLoader__.load({
1292
1302
  try { window.localStorage.setItem(ORDER_STORAGE_KEY, JSON.stringify(ids)); } catch (e) {}
1293
1303
  }
1294
1304
 
1295
- const PANEL_STORAGE_KEY = "dsh-model-organizer.panelOpen";
1296
1305
  const PANEL_POS_KEY = "dsh-model-organizer.panelPos";
1297
1306
 
1298
1307
 
@@ -1311,16 +1320,6 @@ window.__ModuleLoader__.load({
1311
1320
  try { window.localStorage.setItem(PANEL_POS_KEY, JSON.stringify(pos)); } catch (e) {}
1312
1321
  }
1313
1322
 
1314
- /* ALWAYS expanded on mount. A remembered collapse is indistinguishable from
1315
- "the default is collapsed" the next time the page opens, which is not what
1316
- this panel is for. */
1317
- function readPanelOpen() {
1318
- return true;
1319
- }
1320
-
1321
- function writePanelOpen(open) {
1322
- try { window.localStorage.setItem(PANEL_STORAGE_KEY, open ? "1" : "0"); } catch (e) {}
1323
- }
1324
1323
 
1325
1324
  /* Stored order first, then everything else in document order. */
1326
1325
  function applyProviderOrder(ids, preferred) {
@@ -1395,9 +1394,11 @@ window.__ModuleLoader__.load({
1395
1394
  const openState = useState({});
1396
1395
  const openMap = openState[0];
1397
1396
  const setOpenMap = openState[1];
1398
- const panelState = useState(readPanelOpen);
1397
+ /* The panel always mounts expanded: a remembered collapse is
1398
+ indistinguishable from "collapsed by default" on the next page open. */
1399
+ const panelState = useState(true);
1399
1400
  const panelOpen = panelState[0];
1400
- const setPanelOpen = function (next) { writePanelOpen(next); panelState[1](next); };
1401
+ const setPanelOpen = panelState[1];
1401
1402
  const posState = useState(readPanelPos);
1402
1403
  const panelPos = posState[0];
1403
1404
  const setPanelPos = posState[1];
@@ -1481,8 +1482,6 @@ window.__ModuleLoader__.load({
1481
1482
  }, [panelPos, panelOpen]);
1482
1483
 
1483
1484
  const ids = order === null ? baseIds : order;
1484
- const idsKey = ids.join("|");
1485
- const dirty = order !== null && order.join("|") !== sourceKey;
1486
1485
 
1487
1486
  /* The shipped provider cards are left exactly as React renders them. Ordering used
1488
1487
  to be mirrored onto them with inline `order`; that is gone — this plugin adds a
@@ -1606,7 +1605,7 @@ window.__ModuleLoader__.load({
1606
1605
  h("span", { key: "n", className: C !== null ? C.cellLabel : undefined, style: C === null ? S.rowName : undefined }, profile.displayName || id),
1607
1606
  h("span", { key: "c", className: C !== null ? C.cellValue : undefined, style: C === null ? S.rowMeta : undefined }, count + " " + t("composer.count"))
1608
1607
  ];
1609
- const rowChevron = icon("IconChevronRightOutline14", {
1608
+ const rowChevron = icon("IconChevronRightOutlineRegular", {
1610
1609
  key: "v",
1611
1610
  className: C !== null ? cx(C.cellChevron, "dsh-mo-chev") : "dsh-mo-chev",
1612
1611
  style: C === null ? S.groupChevron : undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimoxie/dsh-model-organizer",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "DSH 模型整理插件:输入框的模型下拉改为「供应商分组 + 模型二级折叠菜单」(含推理等级),并在模型设置页提供一个可拖拽的「供应商与模型顺序」浮窗。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",