dsh-research-desk 0.3.0 → 0.3.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/README.md +40 -16
- package/index.json +2 -2
- package/lib/client.js +15 -2
- package/lib/host.mjs +14 -5
- package/lib/llm.mjs +5 -2
- package/lib/mcp.mjs +1 -1
- package/lib/util.mjs +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
DeepSeek Harness 插件:给 agent 和研究者一个**就在侧栏里的科研工作台**——检索文献、维护阅读库、抓全文做带锚点的问答、推可证伪选题、写多视角综述、在受限目录里跑验证脚本、整库导出。
|
|
4
4
|
**每一条引文都回到原文逐字核对,对不上就剔除。**
|
|
5
5
|
|
|
6
|
-
- 包名 `dsh-research-desk`,版本 0.2
|
|
6
|
+
- 包名 `dsh-research-desk`,版本 0.3.2,MIT,零运行时依赖,零构建步骤
|
|
7
7
|
- 宿主要求:DSH `>=0.2.1-rc.5 <0.3.0`,Node `>=22`
|
|
8
8
|
- 交付渠道:GitHub + npm + dshmarket(索引条目见 `index.json`)
|
|
9
9
|
|
|
@@ -34,7 +34,7 @@ DeepSeek Harness 插件:给 agent 和研究者一个**就在侧栏里的科研
|
|
|
34
34
|
|
|
35
35
|
- **输入**:检索式,加三个数据源勾选(arXiv / Europe PMC / OpenAlex);面板固定按单源 12 条请求。
|
|
36
36
|
- **输出**:结果卡片列表,每张卡带来源 / 年份 / venue / 引用数 chip、摘要、「加入文献库」按钮与原文链接。
|
|
37
|
-
- **限制**:三个源都免密钥;单源条数上限由设置 `maxResults` 决定(默认 15,宿主端夹在 1–40);某个源失败不阻断整体,失败原因出现在返回的 `errors` 里;只覆盖这三个开放源,不接付费库。
|
|
37
|
+
- **限制**:三个源都免密钥;单源条数上限由设置 `maxResults` 决定(默认 15,宿主端夹在 1–40);某个源失败不阻断整体,失败原因出现在返回的 `errors` 里;只覆盖这三个开放源,不接付费库。 把 `sources` 设为空数组就真的一个源都不检索(早期版本会把空数组当成没给、退回默认三源,已修)。
|
|
38
38
|
|
|
39
39
|
### 2.2 文献库(library)
|
|
40
40
|
|
|
@@ -92,7 +92,7 @@ DeepSeek Harness 插件:给 agent 和研究者一个**就在侧栏里的科研
|
|
|
92
92
|
|
|
93
93
|
### 3.1 dshmarket 市场安装(推荐)
|
|
94
94
|
|
|
95
|
-
在 dshmarket 的插件市场里找到「科研工作台 / Research Desk」,一键安装。dshmarket 读取的正是精选列表 awesome-dsh-plugin 里的索引条目,版本与 npm 上的 `dsh-research-desk` 对应(当前 0.2
|
|
95
|
+
在 dshmarket 的插件市场里找到「科研工作台 / Research Desk」,一键安装。dshmarket 读取的正是精选列表 awesome-dsh-plugin 里的索引条目,版本与 npm 上的 `dsh-research-desk` 对应(当前 0.3.2)。
|
|
96
96
|
|
|
97
97
|
### 3.2 npm 规格名安装
|
|
98
98
|
|
|
@@ -118,7 +118,7 @@ https://cdn.jsdelivr.net/gh/stallenlu/dsh-research-desk@main/index.json
|
|
|
118
118
|
"format": 1,
|
|
119
119
|
"title": { "en": "Research Desk", "zh": "科研工作台" },
|
|
120
120
|
"description": { "en": "...", "zh": "..." },
|
|
121
|
-
"metadata": { "categories": ["
|
|
121
|
+
"metadata": { "categories": ["tools", "docs"] },
|
|
122
122
|
"plugins": [
|
|
123
123
|
{
|
|
124
124
|
"name": "dsh-research-desk",
|
|
@@ -127,11 +127,11 @@ https://cdn.jsdelivr.net/gh/stallenlu/dsh-research-desk@main/index.json
|
|
|
127
127
|
"author": "stallenlu",
|
|
128
128
|
"homepage": "https://github.com/stallenlu/dsh-research-desk",
|
|
129
129
|
"repository": { "url": "https://github.com/stallenlu/dsh-research-desk" },
|
|
130
|
-
"metadata": { "category": "
|
|
130
|
+
"metadata": { "category": "tools", "keywords": ["research", "literature", "arxiv", "pubmed", "openalex", "科研", "文献"] },
|
|
131
131
|
"versions": [
|
|
132
132
|
{
|
|
133
|
-
"version": "0.2
|
|
134
|
-
"publishTimestamp": "2026-11-18T01:
|
|
133
|
+
"version": "0.3.2",
|
|
134
|
+
"publishTimestamp": "2026-11-18T01:40:00.000Z",
|
|
135
135
|
"source": { "type": "npm" },
|
|
136
136
|
"engines": { "dsh": ">=0.2.1-rc.5 <0.3.0" }
|
|
137
137
|
}
|
|
@@ -248,6 +248,8 @@ Agent 侧只有一个工具:`research_desk`(超时 300 秒,标记为并发
|
|
|
248
248
|
|
|
249
249
|
参数取值:`sources` 是 `arxiv` / `europepmc` / `openalex`;`perspectives` 是 `methodology` / `evidence` / `contradictions` / `gaps` / `applications`;`runtime` 是 `python` / `node`;`kind` 是 `one-sample` / `two-sample-welch` / `paired`;`formats` 是 `md` / `bib` / `json`;`maxResults` 1–40(默认 12)。
|
|
250
250
|
|
|
251
|
+
已知修复:`library` 动作在文献库非空时曾因消息拼接出错而崩溃,现已修好;`sources` 设为空数组现在真的会一个源都不检索。
|
|
252
|
+
|
|
251
253
|
调用示例:
|
|
252
254
|
|
|
253
255
|
```json
|
|
@@ -268,7 +270,7 @@ Agent 侧只有一个工具:`research_desk`(超时 300 秒,标记为并发
|
|
|
268
270
|
|
|
269
271
|
`lib/mcp.mjs` 同时提供一个 stdio 传输的 MCP server,让别的 agent 也能用同一份文献库。
|
|
270
272
|
|
|
271
|
-
- 协议版本 `2024-11-05`,服务名 `dsh-research-desk`,版本 `0.2
|
|
273
|
+
- 协议版本 `2024-11-05`,服务名 `dsh-research-desk`,版本 `0.3.2`,能力声明为 `tools`。
|
|
272
274
|
- stdout 只走 JSON-RPC,诊断日志走 stderr;`notifications/initialized` 不回包。
|
|
273
275
|
- 与桌面面板共用同一个 `state.json` 与同一套 `applyOps` 写路径,**MCP 写入的内容在面板里立刻可见**。
|
|
274
276
|
|
|
@@ -280,20 +282,27 @@ Agent 侧只有一个工具:`research_desk`(超时 300 秒,标记为并发
|
|
|
280
282
|
| `research_library_remove` | `paperId`(必填,取自 `research_library_list`) |
|
|
281
283
|
| `research_export` | `format`(`markdown`/`json`/`bibtex`,缺省 `markdown`)、`paperIds`(缺省导出全部) |
|
|
282
284
|
|
|
283
|
-
|
|
285
|
+
启动命令(包已全局安装时用 bin 名,否则直接跑入口脚本):
|
|
284
286
|
|
|
285
287
|
```bash
|
|
286
|
-
|
|
288
|
+
dsh-research-desk-mcp
|
|
289
|
+
node bin/dsh-research-desk-mcp.mjs
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
包也导出了 MCP 子路径,可以直接 `import`:
|
|
293
|
+
|
|
294
|
+
```js
|
|
295
|
+
import { runMcpStdio } from 'dsh-research-desk/mcp'
|
|
287
296
|
```
|
|
288
297
|
|
|
289
|
-
挂到别的 MCP
|
|
298
|
+
挂到别的 MCP 客户端上:
|
|
290
299
|
|
|
291
300
|
```json
|
|
292
301
|
{
|
|
293
302
|
"mcpServers": {
|
|
294
303
|
"dsh-research-desk": {
|
|
295
304
|
"command": "node",
|
|
296
|
-
"args": ["
|
|
305
|
+
"args": ["/ABS/PATH/dsh-research-desk/bin/dsh-research-desk-mcp.mjs"]
|
|
297
306
|
}
|
|
298
307
|
}
|
|
299
308
|
}
|
|
@@ -332,7 +341,7 @@ node -e "import('./lib/mcp.mjs').then(m => m.runMcpStdio())"
|
|
|
332
341
|
|
|
333
342
|
## 9. 已知限制
|
|
334
343
|
|
|
335
|
-
-
|
|
344
|
+
- **桌面壳(`dsh-app://`)里没验过面板**:验收跑在独立的 web 实例上(http 形态),侧栏入口与面板渲染都确认了;Electron 桌面壳走的是另一条取址路径,尚未实机验证。
|
|
336
345
|
- **外部运行时依赖使用者自己的机器**:探测顺序是设置里的解释器路径 → 常见命令名(`python` / `python3` / `py -3` / `node`)→ DSH 自带运行时;探不到就没有执行环境。
|
|
337
346
|
- **综述与问答的质量取决于库里的全文覆盖**:只抓了摘要的文献不参与综述,也不参与引文核验。
|
|
338
347
|
- **导出的 JSON 默认不含全文片段**:只留片段序号与标题,正文留在本地库里。
|
|
@@ -344,21 +353,36 @@ node -e "import('./lib/mcp.mjs').then(m => m.runMcpStdio())"
|
|
|
344
353
|
|
|
345
354
|
## 10. 开发与测试
|
|
346
355
|
|
|
347
|
-
目录布局一行说明:`lib/` 是全部实现(host / search / qa / review / runner / export / desk / store / settings / stats / llm / mcp / client),`test/` 是 `node:test` 单测与两个联网探针脚本,`docs/` 是本文档目录,`index.json` 是 dshmarket 索引条目。
|
|
356
|
+
目录布局一行说明:`lib/` 是全部实现(host / search / qa / review / runner / export / desk / store / settings / stats / llm / mcp / client),`bin/` 是 MCP stdio 入口脚本,`test/` 是 `node:test` 单测与两个联网探针脚本,`docs/` 是本文档目录,`index.json` 是 dshmarket 索引条目。
|
|
348
357
|
|
|
349
358
|
Windows 上 `node --test` 必须显式给出文件路径(不能只写目录),一次跑完全部单测:
|
|
350
359
|
|
|
351
360
|
```bash
|
|
352
|
-
node --test test/desk.test.mjs test/export.test.mjs test/mcp.test.mjs test/review.test.mjs test/runner.test.mjs test/search.test.mjs test/settings.test.mjs test/stats.test.mjs
|
|
361
|
+
node --test test/desk.test.mjs test/export.test.mjs test/host.test.mjs test/mcp.test.mjs test/bin.test.mjs test/review.test.mjs test/runner.test.mjs test/search.test.mjs test/settings.test.mjs test/stats.test.mjs
|
|
353
362
|
```
|
|
354
363
|
|
|
355
|
-
共
|
|
364
|
+
共 115 个用例,当前全绿。
|
|
356
365
|
|
|
357
366
|
```bash
|
|
358
367
|
node test/live-probe.mjs
|
|
359
368
|
node test/raw-probe.mjs
|
|
360
369
|
```
|
|
361
370
|
|
|
371
|
+
### 真机验收
|
|
372
|
+
|
|
373
|
+
`test/acceptance.mjs` 是一次性把四段全验掉的脚本:它自己拉起一个独立的 web profile 实例(端口被占用就顺延),验收完关掉实例并还原它动过的文献库,不会碰你日常用的 desktop 实例。
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
node test/acceptance.mjs # 全跑(A 环境 / B 非模型动作 / C 四条模型路径 / D 面板与周边)
|
|
377
|
+
node test/acceptance.mjs --skip-model # 跳过需要真实模型的四段
|
|
378
|
+
node test/acceptance.mjs --only=B,D # 只跑指定分组
|
|
379
|
+
node test/acceptance.mjs --keep-state # 不还原文献库
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
四组分别验的是:A 宿主 exe / cli 入口 / profile / 插件安装;B status、models、settings 视图、密钥脱敏、检索、入库、文献库、read;C ask、review、hypothesis、draft 四条真实模型链路;D 侧栏「科研工作台」入口与面板 DOM、导出三格式、外部工具闸门与真跑、MCP stdio 入口。当前结果:**24 项全过,用时约 60 秒**。
|
|
383
|
+
|
|
384
|
+
渲染检查走 CDP(自己起一个带调试端口的 Edge,导航后取 `outerHTML`)——Edge 的 `--dump-dom` 从 Node spawn 出来会吐 0 字节,不能用。
|
|
385
|
+
|
|
362
386
|
发布流程:
|
|
363
387
|
|
|
364
388
|
1. `npm publish`(包名 `dsh-research-desk`,主入口 `lib/host.mjs`,客户端入口 `lib/client.js`)。
|
package/index.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -13,7 +13,20 @@ window.__ModuleLoader__.load({
|
|
|
13
13
|
|
|
14
14
|
const NS = 'dsh-research-desk'
|
|
15
15
|
const PANEL_ID = 'dsh-research-desk'
|
|
16
|
-
|
|
16
|
+
// 路由不带前导斜杠:跟同门插件 dsh-better-sidebar 的做法一致,用页面自己的
|
|
17
|
+
// base 解析,反向代理的目录前缀和桌面壳的 dsh-app:// 都留在前缀里。
|
|
18
|
+
const ROUTE = 'api/research-desk/'
|
|
19
|
+
|
|
20
|
+
// 把宿主路由解析到页面自己的 base 上:去掉 query(启动 token 在那儿)与 hash,
|
|
21
|
+
// 补上尾部斜杠,再用相对路径拼,避免把请求打到源站的根目录。
|
|
22
|
+
function hostRouteUrl(path) {
|
|
23
|
+
const base = typeof document !== 'undefined' && typeof document.baseURI === 'string' ? document.baseURI : ''
|
|
24
|
+
const url = new URL(base === '' ? 'http://dsh.internal/' : base, 'http://dsh.internal/')
|
|
25
|
+
url.search = ''
|
|
26
|
+
url.hash = ''
|
|
27
|
+
if (!url.pathname.endsWith('/')) url.pathname += '/'
|
|
28
|
+
return new URL(String(path).replace(/^\/+/, ''), url.href)
|
|
29
|
+
}
|
|
17
30
|
|
|
18
31
|
const CSS = "body, .rd-root {\n --rd-surface: var(--dsw-alias-bg-layer-1, #ffffff);\n --rd-surface-2: var(--dsw-alias-bg-layer-2, #fafafa);\n --rd-surface-3: var(--dsw-alias-bg-layer-3, #f5f5f5);\n --rd-line: var(--dsw-alias-border-l2, rgba(0,0,0,0.10));\n --rd-text: var(--dsw-alias-label-primary, #0f1115);\n --rd-text-2: var(--dsw-alias-label-secondary, #61666b);\n --rd-text-3: var(--dsw-alias-label-caption, #adb2b8);\n --rd-hover: var(--dsw-alias-interactive-bg-hover, rgba(38,49,72,0.06));\n --rd-inv-bg: var(--dsw-alias-label-primary, #0f1115);\n --rd-inv-fg: var(--dsw-alias-label-primary-foreground, #ffffff);\n --rd-accent: #3b82f6;\n --rd-warn: #f59e0b;\n --rd-error: #f43f5e;\n --rd-ok: #22c55e;\n --rd-radius: 12px;\n --rd-radius-sm: 8px;\n --rd-font: var(--dsw-font-family, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif);\n --rd-mono: var(--ds-font-family-code, ui-monospace, Menlo, monospace);\n}\n.rd-root { font-family: var(--rd-font); color: var(--rd-text); padding: 12px; font-size: 13px; line-height: 1.6; }\n.rd-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }\n.rd-title { font-size: 14px; font-weight: 600; }\n.rd-sub { font-size: 11px; color: var(--rd-text-2); }\n.rd-tabs { display: flex; gap: 16px; border-bottom: 1px solid var(--rd-line); margin-bottom: 12px; }\n.rd-tab { padding: 7px 0 9px; border: 0; background: transparent; color: var(--rd-text-2); font: inherit; font-size: 12px; cursor: pointer; position: relative; }\n.rd-tab:hover { color: var(--rd-text); }\n.rd-tab[data-on='1'] { color: var(--rd-text); font-weight: 500; }\n.rd-tab[data-on='1']::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--rd-text); border-radius: 2px; }\n.rd-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }\n.rd-input { flex: 1 1 240px; min-width: 0; padding: 7px 10px; border: 1px solid var(--rd-line); border-radius: var(--rd-radius-sm); background: var(--rd-surface); color: var(--rd-text); font: inherit; font-size: 12px; }\n.rd-input:focus { outline: 2px solid color-mix(in srgb, var(--rd-accent) 40%, transparent); outline-offset: -1px; }\n.rd-btn { padding: 6px 12px; border: 1px solid var(--rd-line); border-radius: var(--rd-radius-sm); background: transparent; color: var(--rd-text); font: inherit; font-size: 12px; cursor: pointer; }\n.rd-btn:hover:not(:disabled) { background: var(--rd-hover); }\n.rd-btn:disabled { opacity: 0.45; cursor: default; }\n.rd-btn--primary { background: var(--rd-inv-bg); color: var(--rd-inv-fg); border-color: transparent; font-weight: 500; }\n.rd-btn--sm { padding: 3px 8px; font-size: 11px; }\n.rd-card { border: 1px solid var(--rd-line); border-radius: var(--rd-radius); background: var(--rd-surface); padding: 10px 12px; margin-bottom: 8px; }\n.rd-card h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; line-height: 1.45; }\n.rd-meta { font-size: 11px; color: var(--rd-text-2); }\n.rd-abs { font-size: 11px; color: var(--rd-text-2); margin-top: 4px; max-height: 54px; overflow: hidden; }\n.rd-chip { display: inline-block; padding: 1px 6px; border-radius: 9999px; background: var(--rd-surface-3); color: var(--rd-text-2); font-size: 10px; margin-right: 4px; }\n.rd-chip--ok { background: color-mix(in srgb, var(--rd-ok) 16%, transparent); color: var(--rd-ok); }\n.rd-chip--warn { background: color-mix(in srgb, var(--rd-warn) 16%, transparent); color: var(--rd-warn); }\n.rd-chip--err { background: color-mix(in srgb, var(--rd-error) 16%, transparent); color: var(--rd-error); }\n.rd-empty { padding: 26px 10px; text-align: center; color: var(--rd-text-2); font-size: 12px; }\n.rd-msg { font-size: 11px; color: var(--rd-text-2); white-space: pre-wrap; margin-top: 6px; }\n.rd-msg--err { color: var(--rd-error); }\n.rd-cite { border-left: 2px solid var(--rd-accent); padding: 2px 0 2px 8px; margin-top: 6px; font-size: 11px; color: var(--rd-text-2); }\n.rd-cite code { font-family: var(--rd-mono); font-size: 10px; color: var(--rd-text-3); }\n.rd-body { font-size: 12px; white-space: pre-wrap; max-height: 320px; overflow: auto; }\n.rd-hyp { border-left: 2px solid var(--rd-accent); padding-left: 8px; margin-bottom: 10px; }\n.rd-note { font-size: 11px; color: var(--rd-text-3); }\n.rd-area { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--rd-line); border-radius: var(--rd-radius-sm); background: var(--rd-surface); color: var(--rd-text); font-family: var(--rd-mono); font-size: 11px; line-height: 1.5; min-height: 120px; resize: vertical; }\n.rd-area:focus { outline: 2px solid color-mix(in srgb, var(--rd-accent) 40%, transparent); outline-offset: -1px; }\n.rd-tabs { flex-wrap: wrap; gap: 6px 16px; }"
|
|
19
32
|
|
|
@@ -28,7 +41,7 @@ window.__ModuleLoader__.load({
|
|
|
28
41
|
}
|
|
29
42
|
|
|
30
43
|
async function call(payload) {
|
|
31
|
-
const res = await fetch(ROUTE, {
|
|
44
|
+
const res = await fetch(hostRouteUrl(ROUTE).href, {
|
|
32
45
|
method: 'POST',
|
|
33
46
|
headers: { 'content-type': 'application/json' },
|
|
34
47
|
body: JSON.stringify(payload || {}),
|
package/lib/host.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { applyOps, emptyState, migrateState, paperKey } from './desk.mjs'
|
|
|
14
14
|
import { fetchFullText, search } from './search.mjs'
|
|
15
15
|
import { ask as groundedAsk, chunkText } from './qa.mjs'
|
|
16
16
|
import { defaultRoute, listModels, streamText } from './llm.mjs'
|
|
17
|
-
import { cleanText, isObject, parseJsonLoose } from './util.mjs'
|
|
17
|
+
import { cleanBlock, cleanText, isObject, parseJsonLoose } from './util.mjs'
|
|
18
18
|
import { coerceSettings, defaultSettings, describeSettings, readSettings, resolveSecret } from './settings.mjs'
|
|
19
19
|
import { adjustPvalues, oneSampleT, pairedT, parseNumbers, twoSampleWelch } from './stats.mjs'
|
|
20
20
|
import { generateReview, perspectiveKeys } from './review.mjs'
|
|
@@ -266,7 +266,7 @@ export function createService(ctx) {
|
|
|
266
266
|
}
|
|
267
267
|
},
|
|
268
268
|
async models() {
|
|
269
|
-
const rows = listModels(ctx)
|
|
269
|
+
const rows = await listModels(ctx)
|
|
270
270
|
return { ok: true, action: 'models', message: '可用模型 ' + rows.length + ' 个:' + rows.slice(0, 12).map(row => row.provider + '/' + row.model).join('、'), models: rows }
|
|
271
271
|
},
|
|
272
272
|
async settingsView() {
|
|
@@ -522,9 +522,18 @@ export function createService(ctx) {
|
|
|
522
522
|
return { ok: false, action: 'draft', message: '模型调用失败:' + (err && err.message ? err.message : String(err)) }
|
|
523
523
|
}
|
|
524
524
|
const parsed = parseJsonLoose(raw)
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
525
|
+
// The model often answers in prose, or returns JSON that was cut off by the
|
|
526
|
+
// token limit. Salvage prose instead of dropping the whole answer, and echo
|
|
527
|
+
// the raw head when nothing usable is left.
|
|
528
|
+
const jsonBody = parsed && typeof parsed.body === 'string' ? parsed.body : ''
|
|
529
|
+
const fence = raw.indexOf('```')
|
|
530
|
+
const prose = fence >= 0 ? raw.slice(raw.indexOf('\n', fence) + 1, raw.lastIndexOf('```')) : raw
|
|
531
|
+
const usableProse = /^[[{]/.test(prose.trim()) ? '' : prose.trim()
|
|
532
|
+
const title = cleanText(parsed && parsed.title, 400) || cleanText(usableProse.split('\n')[0], 80) || instruction.slice(0, 60)
|
|
533
|
+
const body = cleanBlock(jsonBody || usableProse, 60000)
|
|
534
|
+
if (!body) {
|
|
535
|
+
return { ok: false, action: 'draft', message: '模型没有给出正文。原始输出开头:' + (raw.slice(0, 200) || '(空)') }
|
|
536
|
+
}
|
|
528
537
|
const outcome = await store.mutate('生成草稿', draft => {
|
|
529
538
|
const res = applyOps(draft, [{ op: 'add_draft', title, body, refs: (parsed && Array.isArray(parsed.refs)) ? parsed.refs : [] }])
|
|
530
539
|
draft.updatedAt = new Date().toISOString()
|
package/lib/llm.mjs
CHANGED
|
@@ -22,19 +22,22 @@ export function defaultRoute(ctx) {
|
|
|
22
22
|
return null
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function listModels(ctx) {
|
|
25
|
+
export async function listModels(ctx) {
|
|
26
26
|
const llm = ctx.get('llm')
|
|
27
27
|
if (!llm || typeof llm.listProviders !== 'function') return []
|
|
28
28
|
const providers = llm.listProviders() || []
|
|
29
29
|
const rows = []
|
|
30
30
|
for (const provider of providers) {
|
|
31
|
+
if (!provider || typeof provider.id !== 'string') continue
|
|
31
32
|
let models = []
|
|
32
33
|
try {
|
|
33
|
-
|
|
34
|
+
// The host catalog is asynchronous: listModels() resolves a promise.
|
|
35
|
+
models = (await llm.listModels(provider.id)) || []
|
|
34
36
|
} catch (err) {
|
|
35
37
|
models = []
|
|
36
38
|
}
|
|
37
39
|
for (const model of models) {
|
|
40
|
+
if (!model || typeof model.id !== 'string') continue
|
|
38
41
|
rows.push({ provider: provider.id, model: model.id, label: model.label || model.name || model.id })
|
|
39
42
|
}
|
|
40
43
|
}
|
package/lib/mcp.mjs
CHANGED
package/lib/util.mjs
CHANGED
|
@@ -64,6 +64,17 @@ export function truncate(text, max) {
|
|
|
64
64
|
return value.length <= max ? value : value.slice(0, max - 1) + '…'
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/** Clean prose but keep the line breaks (draft bodies, review paragraphs). */
|
|
68
|
+
export function cleanBlock(value, max) {
|
|
69
|
+
if (typeof value !== 'string') return ''
|
|
70
|
+
return value
|
|
71
|
+
.replace(/\r\n/g, '\n')
|
|
72
|
+
.replace(/[ \t]+\n/g, '\n')
|
|
73
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
74
|
+
.trim()
|
|
75
|
+
.slice(0, max)
|
|
76
|
+
}
|
|
77
|
+
|
|
67
78
|
export function dedupe(list) {
|
|
68
79
|
return Array.from(new Set(list))
|
|
69
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-research-desk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DeepSeek Harness plugin: a research desk for literature discovery, anchored reading, multi-perspective review, hypothesis tracking, sandboxed verification runs and export.",
|
|
6
6
|
"homepage": "https://github.com/stallenlu/dsh-research-desk#readme",
|