dsh-deepseek-web-login 0.6.1 → 0.6.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/CHANGELOG.md +48 -0
- package/lib/index.js +76 -14
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,54 @@
|
|
|
2
2
|
|
|
3
3
|
本项目遵循大致语义化版本;日期为本地时间。
|
|
4
4
|
|
|
5
|
+
## 0.6.2 — 2026-09-27
|
|
6
|
+
|
|
7
|
+
> 长尾工具压成**一行**:`` `签名` — 首句 ``。目录再瘦一圈,能力依然一个不少。
|
|
8
|
+
|
|
9
|
+
### 改进
|
|
10
|
+
|
|
11
|
+
- **长尾工具改成一行格式**,并拆出独立的 `## Other tools` 小节:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
## Available tools
|
|
15
|
+
### pwsh
|
|
16
|
+
<完整描述>
|
|
17
|
+
pwsh(command: string, description: string)
|
|
18
|
+
command: …
|
|
19
|
+
description: …
|
|
20
|
+
|
|
21
|
+
## Other tools
|
|
22
|
+
|
|
23
|
+
Call these the same way. Parameter names and types are in the parentheses.
|
|
24
|
+
|
|
25
|
+
- `job_list(limit?: number)` — 列出后台任务
|
|
26
|
+
- `web_search(queries: string[])` — 联网搜索
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
这是抄 cuckoo 的(它的 `getFormattedJsApiForPrompt` 对每个工具就是 `` 1. `read(path)` — 读取文件 ``):
|
|
30
|
+
**名字 / 签名 / 一句话三样都在,但只占一行** —— 长尾工具的价值就是"让模型知道它存在、怎么传参"。
|
|
31
|
+
- 那句话取**首句**(到第一个句末点)而不是开头若干字,上限 160 字符:描述的第一句才是"这工具干什么"。
|
|
32
|
+
|
|
33
|
+
### 实测收益(13 个真实 DSH 工具定义)
|
|
34
|
+
|
|
35
|
+
| 版本 | 目录长度 | 累计省 |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| 0.5.3(JSON + 完整描述) | 18,217 | — |
|
|
38
|
+
| 0.6.0(签名 + 完整描述) | 14,815 | 19% |
|
|
39
|
+
| 0.6.1(分级:长尾 240 字) | 11,000+ | 42% |
|
|
40
|
+
| **0.6.2(长尾一行)** | **9,024** | **50%** |
|
|
41
|
+
|
|
42
|
+
按 61 个工具(50,942 字符)外推,约 **省 2.5 万字符 ≈ 6,000 token / 每轮上下文**,
|
|
43
|
+
**零额外请求**、**工具一个不少**。
|
|
44
|
+
|
|
45
|
+
### 说明
|
|
46
|
+
|
|
47
|
+
- ⚠️ **这是 head 的变化**:重启 DSH 后**第一个任务会全量重发一次**,之后照常。
|
|
48
|
+
- 🔴 **渲染顺序变了**:以前是"按 DSH 下发的原序",现在是**分组**(核心在前、长尾在后),
|
|
49
|
+
各组**内部**仍保持原序。所以目录里工具的排列与之前不同。
|
|
50
|
+
- 长尾工具丢的是「遇错怎么办」那类长指引;核心工具(真正常用的)一个字没动。
|
|
51
|
+
- 调整名单:改 `src/protocol.ts` 的 `CORE_TOOLS` 集合 —— 那是唯一的开关。
|
|
52
|
+
|
|
5
53
|
## 0.6.1 — 2026-09-27
|
|
6
54
|
|
|
7
55
|
> 工具目录按「用不用得上」分级:常用的给完整说明,长尾的只留一句话。**能力一个不少。**
|
package/lib/index.js
CHANGED
|
@@ -3353,14 +3353,36 @@ const CORE_TOOLS = /* @__PURE__ */ new Set([
|
|
|
3353
3353
|
"ask_user_question"
|
|
3354
3354
|
]);
|
|
3355
3355
|
/**
|
|
3356
|
-
*
|
|
3357
|
-
*
|
|
3356
|
+
* 长尾工具「一行说明」里那句话的上限。
|
|
3357
|
+
*
|
|
3358
|
+
* 长尾工具只占**一行**:`` `name(签名)` — 首句 ``(抄 cuckoo 的 `getFormattedJsApiForPrompt`,
|
|
3359
|
+
* 它对每个工具就是 `` 1. `read(path)` — 读取文件 ``)。
|
|
3360
|
+
* 取**首句**而不是开头 160 字 —— 描述的第一句才是"这工具干什么",后面的多是用法细节。
|
|
3358
3361
|
*/
|
|
3359
|
-
const
|
|
3362
|
+
const MAX_TAIL_DESCRIPTION_CHARS = 160;
|
|
3360
3363
|
/** 工具是否属于核心组(决定描述给多长、要不要带参数说明)。 */
|
|
3361
3364
|
function isCoreTool(name) {
|
|
3362
3365
|
return CORE_TOOLS.has(String(name ?? ""));
|
|
3363
3366
|
}
|
|
3367
|
+
/** 取描述的首句(到第一个句末点),再按上限截断。 */
|
|
3368
|
+
function tailSentence(text) {
|
|
3369
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
3370
|
+
const stop = flat.search(/\.(\s|$)/);
|
|
3371
|
+
return truncate(stop >= 0 ? flat.slice(0, stop + 1) : flat, MAX_TAIL_DESCRIPTION_CHARS);
|
|
3372
|
+
}
|
|
3373
|
+
/**
|
|
3374
|
+
* 长尾工具的**一行**形式:`` `name(签名)` — 首句 ``。
|
|
3375
|
+
*
|
|
3376
|
+
* 名字、签名、一句话三样都在,但只占一行 —— 长尾工具的价值就是"让模型知道它存在、怎么传参"。
|
|
3377
|
+
* ⚠️ 签名认不出来时(`buildToolSignature` 返回 null)不冒险拼一行,只给名字 + 首句,
|
|
3378
|
+
* 让模型知道有这个工具、但不会照着残缺签名瞎传参(它会被兜底文案要求去问用户)。
|
|
3379
|
+
*/
|
|
3380
|
+
function formatTailTool(tool) {
|
|
3381
|
+
const sentence = tailSentence(String(tool.description ?? ""));
|
|
3382
|
+
const signature = buildToolSignature(tool, false);
|
|
3383
|
+
if (signature === null) return `\`${tool.name}\` — ${sentence}`;
|
|
3384
|
+
return `\`${signature.replace(/\s+/g, " ").trim()}\` — ${sentence}`;
|
|
3385
|
+
}
|
|
3364
3386
|
/**
|
|
3365
3387
|
* 工具目录(一节)的总预算。
|
|
3366
3388
|
*
|
|
@@ -3619,17 +3641,35 @@ function buildToolSignature(tool, withParamDocs = true) {
|
|
|
3619
3641
|
/**
|
|
3620
3642
|
* 渲染工具目录。
|
|
3621
3643
|
*
|
|
3622
|
-
*
|
|
3623
|
-
*
|
|
3644
|
+
* 结构(0.6.2):
|
|
3645
|
+
*
|
|
3646
|
+
* ## Available tools ← 核心工具:一段一个(`### 名字` / 完整描述 / 紧凑签名 / 参数说明)
|
|
3647
|
+
* ## Other tools ← 长尾工具:**一行一个** —— `` - `name(签名)` — 首句 ``
|
|
3648
|
+
*
|
|
3649
|
+
* 长尾用一行格式是抄 cuckoo 的(它的 `getFormattedJsApiForPrompt` 对每个工具就是
|
|
3650
|
+
* `` 1. `read(path)` — 读取文件 ``):同样三样信息(名字 / 签名 / 一句话),
|
|
3651
|
+
* 三行能装下的,一行就够 —— 而 61 个工具里有 48 个是长尾。
|
|
3652
|
+
*
|
|
3653
|
+
* ⚠️ **两级都保留工具名与参数签名** ⇒ 模型照样能调用长尾工具,只是看不到长篇说明。
|
|
3624
3654
|
*/
|
|
3625
3655
|
function buildToolSection(tools, maxChars = MAX_TOOLS_SECTION_CHARS) {
|
|
3626
3656
|
if (!tools || tools.length === 0) return "";
|
|
3627
3657
|
const parts = ["", "## Available tools"];
|
|
3628
3658
|
let budget = Math.max(0, Math.min(MAX_TOOLS_SECTION_CHARS, maxChars));
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3659
|
+
const coreTools = tools.filter((tool) => isCoreTool(tool?.name));
|
|
3660
|
+
const tailTools = tools.filter((tool) => !isCoreTool(tool?.name));
|
|
3661
|
+
/**
|
|
3662
|
+
* 预算用尽时的兜底:**必须把剩下的工具名说出来**,并明确要求别猜参数。
|
|
3663
|
+
* 旧写法只有一句 "(remaining tools omitted for length)",模型连"还有哪些工具存在"
|
|
3664
|
+
* 都不知道,只能盲猜名字和参数 —— 实测 61 个工具里 26 个就是这样静默消失的。
|
|
3665
|
+
*/
|
|
3666
|
+
const omittedNotice = (rest) => {
|
|
3667
|
+
const names = rest.map((item) => String(item?.name ?? "")).filter(Boolean);
|
|
3668
|
+
return `\n(⚠️ The following ${names.length} tools are NOT described above (omitted for length): ${names.join(", ")}. If you need one of them, ask the user for its exact parameters — do NOT guess them.)`;
|
|
3669
|
+
};
|
|
3670
|
+
for (let index = 0; index < coreTools.length; index += 1) {
|
|
3671
|
+
const tool = coreTools[index];
|
|
3672
|
+
const signature = buildToolSignature(tool, true);
|
|
3633
3673
|
let parametersText = signature ?? "";
|
|
3634
3674
|
if (signature === null) {
|
|
3635
3675
|
let schemaText = "";
|
|
@@ -3643,17 +3683,39 @@ function buildToolSection(tools, maxChars = MAX_TOOLS_SECTION_CHARS) {
|
|
|
3643
3683
|
const block = [
|
|
3644
3684
|
"",
|
|
3645
3685
|
`### ${tool.name}`,
|
|
3646
|
-
truncate(String(tool.description ?? "").replace(/\s+/g, " ").trim(),
|
|
3686
|
+
truncate(String(tool.description ?? "").replace(/\s+/g, " ").trim(), MAX_DESCRIPTION_CHARS),
|
|
3647
3687
|
parametersText
|
|
3648
3688
|
].join("\n");
|
|
3649
3689
|
if (budget - block.length < 0) {
|
|
3650
|
-
|
|
3651
|
-
parts.
|
|
3652
|
-
break;
|
|
3690
|
+
parts.push(omittedNotice([...coreTools.slice(index), ...tailTools]));
|
|
3691
|
+
return parts.join("\n");
|
|
3653
3692
|
}
|
|
3654
3693
|
budget -= block.length;
|
|
3655
3694
|
parts.push(block);
|
|
3656
3695
|
}
|
|
3696
|
+
if (tailTools.length > 0) {
|
|
3697
|
+
const header = [
|
|
3698
|
+
"",
|
|
3699
|
+
"## Other tools",
|
|
3700
|
+
"",
|
|
3701
|
+
"Call these the same way. Parameter names and types are in the parentheses."
|
|
3702
|
+
].join("\n");
|
|
3703
|
+
if (budget - header.length < 0) {
|
|
3704
|
+
parts.push(omittedNotice(tailTools));
|
|
3705
|
+
return parts.join("\n");
|
|
3706
|
+
}
|
|
3707
|
+
budget -= header.length;
|
|
3708
|
+
parts.push(header);
|
|
3709
|
+
for (let index = 0; index < tailTools.length; index += 1) {
|
|
3710
|
+
const line = `- ${formatTailTool(tailTools[index])}`;
|
|
3711
|
+
if (budget - line.length < 0) {
|
|
3712
|
+
parts.push(omittedNotice(tailTools.slice(index)));
|
|
3713
|
+
break;
|
|
3714
|
+
}
|
|
3715
|
+
budget -= line.length;
|
|
3716
|
+
parts.push(line);
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3657
3719
|
return parts.join("\n");
|
|
3658
3720
|
}
|
|
3659
3721
|
function flattenText(blocks, out = []) {
|
|
@@ -8832,7 +8894,7 @@ async function checkForUpdate(current, fetchImpl) {
|
|
|
8832
8894
|
* 兜底常量与 package.json 的一致性由 `tests/check-smoke.mjs` 守着,不会漂。
|
|
8833
8895
|
*/
|
|
8834
8896
|
/** 与 package.json 保持一致的兜底版本(由测试保证不会漂)。 */
|
|
8835
|
-
const FALLBACK_VERSION = "0.6.
|
|
8897
|
+
const FALLBACK_VERSION = "0.6.2";
|
|
8836
8898
|
let cached;
|
|
8837
8899
|
/** 本插件版本(如 `0.1.26`)。 */
|
|
8838
8900
|
function pluginVersion() {
|