dsh-search-model
Agent 与会话 活跃维护

dsh-search-model

jsoncode/dsh-search-model

提供模型库内的快速搜索能力,支持关键词匹配、结果排序与模糊查询,让开发者无需手动翻找即可迅速定位到目标模型。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
TypeScript
主要语言
MIT
开源协议
73 KB
仓库大小
3 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:jsoncode/dsh-search-model
git clone https://github.com/jsoncode/dsh-search-model.git
git clone git@github.com:jsoncode/dsh-search-model.git
README.md master

dsh-search-model

npm version
Publish
License: MIT

dsh-search-model is a Web-client plugin for the DeepSeek Harness (DSH). It takes
over the composer's Model & reasoning effort menu and adds an instant fuzzy
search box at the top of the Model list, filtering every configured model as
you type.

  • Non-invasive — renders through the slot system only; uninstalling restores
    the stock UI byte-for-byte
  • Case-insensitive substring search — multi-keyword AND, contiguous match
    (glm hits GLM-4.6, never google)
  • Zero-jitter popup — the menu width is measured once on real content and
    locked while you filter
  • Shared state — selections echo between this menu, the composer trigger and
    the /model command palette

中文文档

Features

  • Slot takeover without patching the host: registers into the
    conversation.input.model single seat at a lower shadowing priority
    (priority: -1, lowest renders), replacing the built-in selector with an
    enhanced clone of the same two-level menu (Model / Effort rows → sub-lists).
  • Panel-scoped search box: the input appears only inside the Model sub-list
    (the root two-row view stays stock). It auto-focuses on entry; Esc
    clears the query first, then leaves the pane, then closes the menu.
  • Contiguous-substring matching: lowercased token AND; every keyword must
    appear as a contiguous substring of provider display name / provider id /
    model name / model id / description. No character-skipping subsequence
    matches, so out-of-order input like glm never surfaces google.
  • Live filtering: groups with zero hits are hidden; clearing the query
    restores the full catalog. A "no matches" empty state replaces the list when
    nothing matches.
  • Popup width lock: when the Model pane opens with the catalog settled and
    an empty query, the menu's natural content width is measured once and pinned
    in px — typing cannot resize the card. Leaving the pane / closing the menu /
    re-entering resets and re-measures. The decorative native 420px max-width cap
    is dropped (a viewport-safety bound remains), so long model names and
    descriptions are never clipped by the card itself.
  • Data parity with the host: the plugin prefers the core
    ctx.modelDirectories service — the exact per-session directory instance the
    /model popup uses — so loading state, failures/retries, reasoning-effort
    switching and the "current selection" echo all behave identically. If that
    service is absent (host drift), it falls back to a lightweight built-in
    directory speaking the same session.models / session.selectModel wire.

Installation

Requires a DSH installation with the web profile.

# From npm (once published)
dsh plugin --profile web add dsh-search-model

# From a GitHub Release tarball
dsh plugin --profile web add ./dsh-search-model-0.1.2.tgz

# From a local checkout (development)
dsh plugin --profile web add ./

Verify the bundle layer landed, then start / restart the host:

dsh --profile web --dump-config   # shows a "# == dsh-search-model" layer
dsh --profile web                 # restart required to pick up lib/client.js

Installing from source via github: direct add does not work for this
package (there is no prepare script by design): git installs fetch sources,
which have no built lib/. Download the release tarball instead, or install
from npm.

Usage

  1. Open any session in the DSH Web GUI.
  2. Click the model chip at the right end of the composer tool row (left of
    the send button).
  3. In the Model & reasoning effort menu, open 模型 / Model.
  4. Type in the search box on top — the list filters instantly (case ignored,
    multiple keywords AND-ed).
  5. Pick a hit to select it; the selection syncs everywhere (trigger label,
    /model, effort list).

Uninstall:

dsh plugin --profile web remove dsh-search-model

Development

pnpm install
pnpm check     # type-check (tsc -b --pretty false)
pnpm build     # rm lib && tsc -b && tsdown → lib/index.js (host ESM) + lib/client.js (browser factory)
pnpm watch     # rebuild client bundle on change
pnpm verify    # simulate the host __ModuleLoader__ boot against lib/client.js

Release flow (maintainers):

pnpm release       # check → build → verify → npm version patch → push tag
                   # the v* tag triggers .github/workflows/publish.yml:
                   # build → pack → GitHub Release → npm Trusted Publishing
pnpm publish:npm   # manual local publish channel (runs the full pre-flight)

Structure

├── src/host/index.ts              # Minimal host-half anchor (Loader entry + dsh.client discovery)
├── src/client/
│   ├── index.ts                   # Plugin module: style injection + conversation.input.model takeover
│   ├── face.ts                    # Seat inject-face resolution (shared ctx.modelDirectories, fallback directory)
│   ├── SearchModelSelect.tsx      # Seat component: two-level menu + panel search + width lock
│   ├── fuzzy.ts                   # Case-insensitive contiguous-substring matcher (token AND)
│   ├── store.ts                   # Lightweight snapshot store for the fallback path
│   ├── styles.ts                  # Style injection (dsm-* classes over host --dsw-* tokens)
│   └── types.ts                   # Local mirrors of the wire contracts (zero runtime deps)
├── lib/                           # Build artifacts (index.js, client.js, types/) — see files[]
├── scripts/verify-client.mjs      # Host-seed simulation check for the browser bundle
├── tsdown.config.ts               # Build config (node half + __ModuleLoader__ banner wrapper)
├── tsconfig{,.host,.client}.json  # Solution + two isolated aggregates
├── cordis.patch.yml               # Bundle patch row (plugin referenced by package name)
└── package.json                   # dsh.bundle + dsh.client(web) manifests

Compatibility

  • Built against @deepseek-ai/* 0.1.0-rc releases; peer ranges accept ^0.1.0-rc.6.
  • All @deepseek-ai/* imports are type-only — runtime externals stay inside the
    host seed module table (react, react/jsx-runtime, react-dom,
    @deepseek-ai/dsh-client-ui-primitives), enforced by verify.

License

MIT © jsoncode