dsh-deepseek-web-login 0.6.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  本项目遵循大致语义化版本;日期为本地时间。
4
4
 
5
+ ## 0.6.1 — 2026-09-27
6
+
7
+ > 工具目录按「用不用得上」分级:常用的给完整说明,长尾的只留一句话。**能力一个不少。**
8
+
9
+ ### 改进
10
+
11
+ - **工具描述分两级下发**。0.6.0 把参数从 JSON 换成签名之后,目录里最大的一块变成了
12
+ **工具级描述**(13 个真实工具实测:描述 10,369 字符 vs 参数段 7,588)。现在:
13
+ - **核心工具** —— `pwsh` / `bash` / `run_code` / `read` / `write` / `edit` / `grep` / `glob` /
14
+ `ls` / `todo_write` / `skill` / `present` / `ask_user_question`:描述按 3200 字符完整保留,参数说明也在;
15
+ - **长尾工具** —— 描述压到 240 字符,且**不输出参数说明**。
16
+ - ⚠️ **两级都保留工具名与参数签名** ⇒ 模型照样能调用长尾工具,只是看不到长篇说明。
17
+ **这不是「禁用工具」**,不会出现「要用的工具看不见」。
18
+
19
+ ### 为什么这么分(实测依据)
20
+
21
+ 扫最近 8 个会话的 **826 次真实工具调用**:
22
+
23
+ | 工具 | 次数 | 占比 |
24
+ |---|---|---|
25
+ | pwsh | 230 | 27.8% |
26
+ | run_code | 206 | 24.9% |
27
+ | edit | 140 | 16.9% |
28
+ | read | 80 | 9.7% |
29
+ | write | 66 | 8.0% |
30
+ | bash | 46 | 5.6% |
31
+ | 其余(grep/glob/present/skill/todo_write…) | 58 | 7.1% |
32
+
33
+ **覆盖 90% 的调用只需要 6 个工具**,而 DSH 每轮下发 **61 个**。剩下的那些
34
+ (jobs / goal / ralph / workflow / web / subagent 系列…)在这 8 个会话里**一次都没被调用过**,
35
+ 却每个都在每一轮的上下文里占几百字符。
36
+
37
+ ### 实测收益(13 个真实 DSH 工具定义)
38
+
39
+ | 版本 | 目录长度 | 累计省 |
40
+ |---|---|---|
41
+ | 0.5.3(JSON + 完整描述) | 18,217 | — |
42
+ | 0.6.0(签名 + 完整描述) | 14,815 | 19% |
43
+ | **0.6.1(分级)** | **10,544** | **42%** |
44
+
45
+ 按 61 个工具(50,942 字符)外推,约 **省 2.1 万字符 ≈ 5,000 token / 每轮上下文**,
46
+ 而且**零额外请求**。
47
+
48
+ ### 说明
49
+
50
+ - ⚠️ **这是 head 的变化**:重启 DSH 后**第一个任务会全量重发一次**,之后照常。
51
+ - 长尾工具丢的是「遇错怎么办」那类长指引;**真正常用的工具一个字没动**。
52
+ - 想调整名单:改 `src/protocol.ts` 里的 `CORE_TOOLS` 集合 —— 那是唯一的开关。
53
+ 哪天真觉得某个工具"看不懂了",把它加进去重新构建即可。
54
+
5
55
  ## 0.6.0 — 2026-09-27
6
56
 
7
57
  > 工具目录改用**紧凑类型签名**下发,不再给模型贴原始 JSON。
package/lib/index.js CHANGED
@@ -3325,6 +3325,43 @@ function staleAuthMessage(auth) {
3325
3325
  */
3326
3326
  const MAX_DESCRIPTION_CHARS = 3200;
3327
3327
  /**
3328
+ * 「核心工具」白名单 —— 只有它们值得在**每轮上下文**里都带上完整描述。
3329
+ *
3330
+ * 依据(2026-09-27 实测):扫最近 8 个会话的 **826 次真实工具调用**,
3331
+ * pwsh 27.8% / run_code 24.9% / edit 16.9% / read 9.7% / write 8.0% / bash 5.6%
3332
+ * ⇒ **覆盖 90% 的调用只需要这几个**。
3333
+ * 其余 50 多个工具(jobs / goal / ralph / workflow / web / subagent / cordis_*…)
3334
+ * 在那 8 个会话里**一次都没被调用过**,却每个都在每轮上下文里占几百字符。
3335
+ *
3336
+ * ⚠️ 分级只压**说明文字**:工具名与参数签名字字不少 ⇒ 模型照样能调用它们,
3337
+ * 只是看不到长篇说明("遇错怎么办"那类指引只对常用工具才值得每轮都带着)。
3338
+ * 要调整就把名字增删进这个集合 —— 这是唯一的开关。
3339
+ */
3340
+ const CORE_TOOLS = /* @__PURE__ */ new Set([
3341
+ "pwsh",
3342
+ "bash",
3343
+ "run_code",
3344
+ "read",
3345
+ "write",
3346
+ "edit",
3347
+ "grep",
3348
+ "glob",
3349
+ "ls",
3350
+ "todo_write",
3351
+ "skill",
3352
+ "present",
3353
+ "ask_user_question"
3354
+ ]);
3355
+ /**
3356
+ * 长尾工具的描述上限。240 字符 ≈ 首句 + 一句补充,够模型判断"这工具干什么"。
3357
+ * ⚠️ 长尾工具**也不输出参数描述**(参数名/类型/必填性仍在签名里)—— 那是它们体积的另一半。
3358
+ */
3359
+ const MAX_LONGTAIL_DESCRIPTION_CHARS = 240;
3360
+ /** 工具是否属于核心组(决定描述给多长、要不要带参数说明)。 */
3361
+ function isCoreTool(name) {
3362
+ return CORE_TOOLS.has(String(name ?? ""));
3363
+ }
3364
+ /**
3328
3365
  * 工具目录(一节)的总预算。
3329
3366
  *
3330
3367
  * 2026-09-12 从 24_000 提到 56_000。理由:实测 DSH 下发 61 个工具、不截描述时共需
@@ -3557,8 +3594,11 @@ function renderParamType(schema, depth) {
3557
3594
  *
3558
3595
  * ⚠️ 返回 `null` = "这份 parameters 不敢降级",调用方必须回退到原始 JSON:
3559
3596
  * 宁可多花字符,也不能让模型看不见参数。
3597
+ *
3598
+ * @param withParamDocs 是否附上每个参数的说明。核心工具传 `true`,长尾工具传 `false`
3599
+ * —— 签名里已经有参数名、类型、必填性,那是模型写出正确 arguments 的**最小信息集**。
3560
3600
  */
3561
- function buildToolSignature(tool) {
3601
+ function buildToolSignature(tool, withParamDocs = true) {
3562
3602
  try {
3563
3603
  const node = asRecord(tool.parameters);
3564
3604
  if (!node) return `${tool.name}()`;
@@ -3567,7 +3607,7 @@ function buildToolSignature(tool) {
3567
3607
  const args = renderParamMap(map, wrapped && Array.isArray(node.required) ? node.required.filter((key) => typeof key === "string") : [], 1);
3568
3608
  if (args.length === 0) return Object.keys(node).length === 0 ? `${tool.name}()` : null;
3569
3609
  const lines = [`${tool.name}(${args.join(", ")})`];
3570
- for (const [name, def] of Object.entries(map)) {
3610
+ if (withParamDocs) for (const [name, def] of Object.entries(map)) {
3571
3611
  const description = paramDescription(def);
3572
3612
  if (description) lines.push(` ${name}: ${truncate(description, MAX_PARAM_DESC_CHARS)}`);
3573
3613
  }
@@ -3588,7 +3628,8 @@ function buildToolSection(tools, maxChars = MAX_TOOLS_SECTION_CHARS) {
3588
3628
  let budget = Math.max(0, Math.min(MAX_TOOLS_SECTION_CHARS, maxChars));
3589
3629
  for (let index = 0; index < tools.length; index += 1) {
3590
3630
  const tool = tools[index];
3591
- const signature = buildToolSignature(tool);
3631
+ const core = isCoreTool(tool.name);
3632
+ const signature = buildToolSignature(tool, core);
3592
3633
  let parametersText = signature ?? "";
3593
3634
  if (signature === null) {
3594
3635
  let schemaText = "";
@@ -3602,7 +3643,7 @@ function buildToolSection(tools, maxChars = MAX_TOOLS_SECTION_CHARS) {
3602
3643
  const block = [
3603
3644
  "",
3604
3645
  `### ${tool.name}`,
3605
- truncate(String(tool.description ?? "").replace(/\s+/g, " ").trim(), MAX_DESCRIPTION_CHARS),
3646
+ truncate(String(tool.description ?? "").replace(/\s+/g, " ").trim(), core ? MAX_DESCRIPTION_CHARS : MAX_LONGTAIL_DESCRIPTION_CHARS),
3606
3647
  parametersText
3607
3648
  ].join("\n");
3608
3649
  if (budget - block.length < 0) {
@@ -8791,7 +8832,7 @@ async function checkForUpdate(current, fetchImpl) {
8791
8832
  * 兜底常量与 package.json 的一致性由 `tests/check-smoke.mjs` 守着,不会漂。
8792
8833
  */
8793
8834
  /** 与 package.json 保持一致的兜底版本(由测试保证不会漂)。 */
8794
- const FALLBACK_VERSION = "0.6.0";
8835
+ const FALLBACK_VERSION = "0.6.1";
8795
8836
  let cached;
8796
8837
  /** 本插件版本(如 `0.1.26`)。 */
8797
8838
  function pluginVersion() {