@kangyishuai/dsh-advisor 0.5.1 → 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/README.md CHANGED
@@ -21,6 +21,11 @@ This is an **on-demand** advisor, not a passive reviewer. The main model decides
21
21
  - **`off` / `shadow` / `advisory`.** Off by default. `shadow` runs one consultation after each normally completed turn and records it without injecting it; `advisory` is the live mode.
22
22
  - **Cross-provider by design.** The advisor route is independent of the main model. Different model families miss different things, which is the point of a second opinion — but read [Cost & privacy](#cost--privacy) before pointing it at another vendor.
23
23
  - **Budgets and a ledger.** Per turn, per session, per hour and a per-day cost ceiling, plus a token ledger at `<DSH_HOME>/advisor/usage.jsonl`. DSH does not record usage for extra model calls, so the plugin records it itself.
24
+ - **A decision log, so "should it have asked?" can be answered with data.** `<DSH_HOME>/advisor/decisions.jsonl` gets
25
+ **one row per turn** (including turns with no consultation): whether it consulted, the reason code when it did not,
26
+ answer length / tool calls / errors, and whether the user's next message followed the advice.
27
+ `pnpm advisor:review` reports consult and acceptance rates per bucket and lists two kinds of suspects:
28
+ probably-missed and probably-wasted. Local file only — no network, no change to when it consults.
24
29
 
25
30
  ### What it is not
26
31
 
@@ -53,7 +58,7 @@ Re-run `pnpm pack` + `add` after changing the code. The plugin has a host half a
53
58
 
54
59
  Settings live in one JSON file, `<DSH_HOME>/advisor.settings.json` (`DSH_HOME` defaults to `~/.dsh`; the plugin's `dataRoot` config overrides it). The host re-reads the file before each consultation (1 s cache), so editing it applies to the next call without a restart. Unknown keys are dropped, out-of-range numbers are clamped, and a corrupt file falls back to the defaults. **The default is `off`** — a plugin that spends money and sends conversation content stays opt-in.
55
60
 
56
- **Settings UI.** Settings → General → Advisor. With the default `off`, the card shows only the mode, a one-line status and “Configure advisor”. Expanding or enabling it reveals:
61
+ **Settings UI.** Settings → **Advisor** (its own section now, no longer buried in General). The first screen is three rows: mode, route, budget; everything else sits in a “More settings” fold that starts collapsed. With the default `off`, the card shows only the mode, a one-line status and “Configure advisor”. Enabling it reveals:
57
62
 
58
63
  - **Basics**: mode, currency, provider, model, reasoning effort, daily budget, send scope, redaction.
59
64
  - **Advanced** (folded by default): call limits, workspace limits, CNY-per-USD rate, prices (including cache read/write), output/input caps, advice-item cap, allowlist, auto-review, file reading, shadow dedupe, sent-content recording. The heading shows “Defaults” or “N changed”.
@@ -162,10 +167,10 @@ This is the section to read before turning it on.
162
167
 
163
168
  ## Compatibility
164
169
 
165
- | DSH version | Status |
166
- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
167
- | 0.2.2-rc.2 | Verified 2026-11-12: unit tests + `pnpm probe:runtime` 67/67 + web `pnpm smoke:advisor` 13/13 on a throwaway DSH home (no model calls, ledger 0). Desktop read-only regression (live app over CDP): 18 passing + 1 skipped (the session had no advisor records). |
168
- | 0.2.2-rc.1 | Verified on this version: unit tests (settings clamping, route selection and pairing, budget guard, transcript rendering, redaction, output contract) and `pnpm probe:runtime`; the desktop read-only regression is `pnpm smoke:advisor-desktop`. Other DSH versions are not verified. |
170
+ | DSH version | Status |
171
+ | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
172
+ | 0.2.2-rc.2 | **0.6.0** (2026-11-14): adds the decision log `decisions.jsonl` plus `pnpm advisor:review`; settings moved to their own "Settings → Advisor" section (three-row summary + collapsed "More settings"). Verified: unit tests (20 of them cover the decision log) + `pnpm probe:runtime` 72/72 + web `pnpm smoke:advisor` **14/14** (throwaway DSH home, no model calls). The settings section was additionally checked on a live desktop build via read-only CDP (DOM + screenshot); the desktop read-only regression reports **19 PASS + 1 SKIP** (the SKIP is a session with no advisor record — the script never fabricates a consultation). |
173
+ | 0.2.2-rc.1 | Verified on this version: unit tests (settings clamping, route selection and pairing, budget guard, transcript rendering, redaction, output contract) and `pnpm probe:runtime`; the desktop read-only regression is `pnpm smoke:advisor-desktop`. Other DSH versions are not verified. |
169
174
 
170
175
  The plugin declares no `engines.dsh` and no `@deepseek-ai/*` peer range: DSH is pre-release and semver ranges over prereleases are unreliable (see [ADR 0005](../../docs/adr/0005-dsh-version-compatibility.md)). Treat this table as the compatibility statement. After a DSH upgrade run `pnpm probe:runtime`, `pnpm smoke:advisor-desktop` and the unit tests, then check `/advisor doctor`.
171
176
 
@@ -186,7 +191,7 @@ Nothing else: no workspace files, no session-log records of its own (a consultat
186
191
  - **Pairing needs your declaration.** DSH has no cross-vendor capability catalog, so "is the advisor at least as strong as the main model" can only come from your `tiers`. Without an entry the result says **unverified** and the consultation proceeds; it never pretends the check passed. With `pairingEnforcement: "block"` a lower declared tier rejects the consultation.
187
192
  - **Token counts can be low on an aborted call.** If a consultation is cancelled or times out, no usage chunk may arrive; the ledger then records the call with zero tokens and a cost budget can lag real spend. Treat the ledger as a good estimate, not an invoice.
188
193
  - **The advisor route can be broken from outside this plugin** (wrong base URL, missing key, rate limit). Every failure becomes a structured tool result (`MISSING_CREDENTIAL`, `rate_limited`, `overloaded`, `prompt_too_long`, `timeout`, `aborted`, …) and never breaks the turn.
189
- - **The settings card lives at the bottom of Settings → General.** It may need scrolling; keys marked JSON-only still need the settings file, and the `/advisor` picker remains available.
194
+ - **The settings live in their own Settings → Advisor section**, with a three-row summary on top and a collapsed “More settings” fold. Keys marked JSON-only still need the settings file, and the `/advisor` picker remains available.
190
195
  - **Partially enforced knobs.** `sessionCap` caps delivered advice per session (blockers exempt); `dedupe` / `immuneTurns` only matter on the shadow path — see [Configure](#configure).
191
196
  - **One attempt, not a retry loop.** A malformed advisor answer is reported as unavailable rather than retried; an unsupported thinking effort is retried exactly once without an effort.
192
197
  - **`shadow` mode still spends quota.** It skips the injection, not the call. And while `shadow` is on, an explicit `advisor` tool call still returns its advice: the mode suppresses the automatic end-of-turn review, not a model-initiated consultation. Use `off` to stop all calls.
package/README.zh-CN.md CHANGED
@@ -21,6 +21,10 @@
21
21
  - **`off` / `shadow` / `advisory` 三种模式。** 默认 `off`。`shadow` 在每个正常完成的回合后徵询一次并记账,但不把建议回灌;`advisory` 是正式模式。
22
22
  - **天生可跨厂商。** 顾问路由独立于主模型。不同模型族的盲区不一样,这正是「第二意见」的意义——但指向另一家之前,请先读[成本与隐私](#成本与隐私)。
23
23
  - **有预算,有账本。** 每回合、每会话、每小时三个次数上限,外加每日金额上限;token 记在 `<DSH_HOME>/advisor/usage.jsonl`。DSH 不会为这种额外模型调用记 usage,所以插件自己记。
24
+ - **有决策日志,可以事后复盘「该不该问」。** `<DSH_HOME>/advisor/decisions.jsonl` **一个回合一行**(没徵询的回合也记),
25
+ 记下是否徵询、没徵询的原因码、回答长度/工具调用数/是否报错,以及徵询后用户的下一条消息是否照着建议做。
26
+ `pnpm advisor:review` 会按桶统计徵询率与采纳率,并列出两类可疑样本:疑似漏徵询、疑似无效徵询。
27
+ 这样「什么时候该徵询」是用数据定的,而不是拍脑袋。只写本地文件,不联网、不改变徵询时机。
24
28
 
25
29
  ### 它不是什么
26
30
 
@@ -53,7 +57,8 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-advisor-*.tgz
53
57
 
54
58
  插件设置只有一个 JSON 文件:`<DSH_HOME>/advisor.settings.json`(`DSH_HOME` 默认 `~/.dsh`,插件配置里的 `dataRoot` 可覆盖)。宿主在每次徵询前重读(1 秒缓存),所以改文件对下一次调用立即生效,不用重启。未知键会被丢弃,越界的数字会被夹紧到区间,文件损坏则回落到默认值。**默认是 `off`**——一个会花钱、会把会话内容发出去的插件必须显式开启。
55
59
 
56
- **设置页。** 设置 → 通用 → 顾问。默认 `off` 时卡片只显示模式、一句状态和「配置顾问」;展开或启用后才显示:
60
+ **设置页。** 设置 → **顾问**(独立分节,不再挤在通用设置里)。首屏只有三行摘要:模式、路由、预算;
61
+ 其余项收进「更多设置」折叠,默认收起。默认 `off` 时只显示模式、一句状态和「配置顾问」;启用后才显示:
57
62
 
58
63
  - **基础**:模式、币种、服务商、模型、思考档、每日预算、发送范围、发送前脱敏。
59
64
  - **高级**(默认折叠):调用限额、工作区限额、人民币汇率、单价(含缓存读取/写入)、输出/输入上限、建议条数、白名单、答后复查、读文件核实、影子去重、记录发送内容;折叠标题会标出「默认值」或「N 项已修改」。
@@ -152,10 +157,10 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-advisor-*.tgz
152
157
 
153
158
  ## 兼容性
154
159
 
155
- | 已验证的 DSH 版本 | 状态 |
156
- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
157
- | 0.2.2-rc.2 | 2026-11-12 已验证:单测 + `pnpm probe:runtime` 67/67 + Web `pnpm smoke:advisor` 13/13(临时 DSH home,不发起模型调用,账本 0)。桌面只读回归(live 桌面版,CDP):18 PASS + 1 SKIP(SKIP 是该会话没有顾问记录)。 |
158
- | 0.2.2-rc.1 | 已在该版本验证:单测(81 条)与 `pnpm probe:runtime`;web 端到端冒烟 `pnpm smoke:advisor`、桌面端只读回归 `pnpm smoke:advisor-desktop`。其他 DSH 版本未验证。 |
160
+ | 已验证的 DSH 版本 | 状态 |
161
+ | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
162
+ | 0.2.2-rc.2 | **0.6.0**(2026-11-14):新增决策日志 `decisions.jsonl` + `pnpm advisor:review` 复盘;设置搬到「设置 → 顾问」分节(首屏三行摘要 + 更多设置折叠)。已验证:单测(含 `decisions` 20 项、linter 全绿)+ `pnpm probe:runtime` 72/72 + web `pnpm smoke:advisor` **14/14**(临时 DSH home,不发起模型调用)。设置分节另有真机只读 CDP 核验(DOM + 截图:三行摘要、更多设置默认收起);桌面只读回归 **19 PASS + 1 SKIP**(SKIP 是该会话没有顾问记录,脚本不制造徵询)。 |
163
+ | 0.2.2-rc.1 | 已在该版本验证:单测(81 条)与 `pnpm probe:runtime`;web 端到端冒烟 `pnpm smoke:advisor`、桌面端只读回归 `pnpm smoke:advisor-desktop`。其他 DSH 版本未验证。 |
159
164
 
160
165
  插件不声明 `engines.dsh`,也不声明 `@deepseek-ai/*` 的 peer 范围:DSH 还在预发布阶段,semver 对预发布版本不可靠(见 [ADR 0005](../../docs/adr/0005-dsh-version-compatibility.md))。这张表就是兼容性声明。DSH 升级后请跑 `pnpm probe:runtime`、`pnpm smoke:advisor-desktop` 和单测,再看 `/advisor doctor`。
161
166
 
package/lib/client.js CHANGED
@@ -77,6 +77,13 @@ window.__ModuleLoader__.load({
77
77
  "settings.group.budget": "预算",
78
78
  "settings.group.privacy": "隐私",
79
79
  "settings.group.advanced": "高级与状态",
80
+ "settings.group.more": "更多设置",
81
+ "settings.nav": "顾问",
82
+ "settings.summary.mode": "模式",
83
+ "settings.summary.route": "路由",
84
+ "settings.summary.budget": "预算",
85
+ "settings.route.unset": "还没选",
86
+ "settings.budget.unlimited": "不限",
80
87
  "settings.mode": "模式",
81
88
  "settings.mode.off": "关闭(off)",
82
89
  "settings.mode.offHint": "不发起任何徵询,也不产生费用。",
@@ -214,6 +221,13 @@ window.__ModuleLoader__.load({
214
221
  "settings.group.budget": "Budgets",
215
222
  "settings.group.privacy": "Privacy",
216
223
  "settings.group.advanced": "Advanced & status",
224
+ "settings.group.more": "More settings",
225
+ "settings.nav": "Advisor",
226
+ "settings.summary.mode": "Mode",
227
+ "settings.summary.route": "Route",
228
+ "settings.summary.budget": "Budget",
229
+ "settings.route.unset": "not chosen",
230
+ "settings.budget.unlimited": "Unlimited",
217
231
  "settings.mode": "Mode",
218
232
  "settings.mode.off": "Off",
219
233
  "settings.mode.offHint": "Never consult the advisor and never spend.",
@@ -317,6 +331,13 @@ window.__ModuleLoader__.load({
317
331
  ".dsh-advisor-toast-mark{font-weight:600;line-height:1.4;}",
318
332
  ".dsh-advisor-toast-text{flex:1;min-width:0;word-break:break-word;white-space:pre-wrap;}",
319
333
  ".dsh-advisor-settings{display:flex;flex-direction:column;gap:12px;font-size:13px;line-height:1.5;color:var(--dsw-alias-label-primary,CanvasText);}",
334
+ // 设置分节的首屏摘要:三行只读信息 + 一个紧凑的模式下拉。
335
+ ".dsh-advisor-summary{display:flex;flex-direction:column;gap:0;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.22));border-radius:8px;overflow:hidden;}",
336
+ ".dsh-advisor-summary-row{display:flex;align-items:center;gap:12px;padding:9px 12px;min-height:38px;}",
337
+ ".dsh-advisor-summary-row+.dsh-advisor-summary-row{border-top:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.16));}",
338
+ ".dsh-advisor-summary-label{flex:none;width:4.5em;color:var(--dsw-alias-label-secondary,#a4a4a4);}",
339
+ ".dsh-advisor-summary-value{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
340
+ ".dsh-advisor-select-compact{max-width:min(320px,100%);}",
320
341
  ".dsh-advisor-head{display:flex;flex-direction:column;gap:2px;}",
321
342
  ".dsh-advisor-title{font-size:14px;font-weight:600;}",
322
343
  ".dsh-advisor-desc{font-size:12px;color:var(--dsw-alias-label-secondary,GrayText);}",
@@ -1849,6 +1870,10 @@ window.__ModuleLoader__.load({
1849
1870
  return [value, set];
1850
1871
  }
1851
1872
 
1873
+ // 「更多设置」默认收起:首屏只留模式/路由/预算三行。
1874
+ let moreState = useUiState("more", false);
1875
+ let moreOpen = moreState[0];
1876
+ let setMoreOpen = moreState[1];
1852
1877
  let advancedState = useUiState("advanced", false);
1853
1878
  let advancedOpen = advancedState[0];
1854
1879
  let setAdvancedOpen = advancedState[1];
@@ -3631,20 +3656,63 @@ window.__ModuleLoader__.load({
3631
3656
  let showForm = draft.mode !== "off" || offExpanded;
3632
3657
  let dirty = isDirty();
3633
3658
 
3659
+ // ---- 首屏摘要:模式 / 路由 / 预算 ----
3660
+ // 设置从「通用设置里的一大张卡」搬进独立分节后,首屏只留三行;
3661
+ // 其余项收进「更多设置」折叠,默认收起(偏好仍然是可改的,只是不占首屏)。
3662
+ let routeText =
3663
+ (draft.provider === "" ? t("settings.route.unset") : draft.provider) +
3664
+ (draft.model === "" ? "" : ` / ${draft.model}`) +
3665
+ (draft.reasoningEffort === "" || draft.reasoningEffort === undefined
3666
+ ? ""
3667
+ : ` · ${draft.reasoningEffort}`);
3668
+ let budgetText =
3669
+ draft.maxCostPerDay > 0
3670
+ ? `${draft.maxCostPerDay} ${draft.currency}`
3671
+ : t("settings.budget.unlimited");
3672
+ /** @param {string} label @param {string} value */
3673
+ const summaryRow = (label, value) =>
3674
+ h("div", { className: "dsh-advisor-summary-row", key: label }, [
3675
+ h("span", { className: "dsh-advisor-summary-label", key: "label" }, label),
3676
+ h("span", { className: "dsh-advisor-summary-value", key: "value" }, value),
3677
+ ]);
3678
+ let modeSelect = h(
3679
+ "select",
3680
+ {
3681
+ className: "dsh-advisor-select dsh-advisor-select-compact",
3682
+ "data-advisor-select": "mode",
3683
+ key: "modeSelect",
3684
+ onChange: function onCompactModeChange(/** @type {any} */ event) {
3685
+ chooseMode(String(event.target.value));
3686
+ },
3687
+ value: draft.mode,
3688
+ },
3689
+ SETTINGS_MODES.map((/** @type {string} */ value) =>
3690
+ h("option", { key: value, value: value }, t(`settings.mode.${value}`)),
3691
+ ),
3692
+ );
3693
+ let summary = h("div", { className: "dsh-advisor-summary", "data-advisor-summary": "" }, [
3694
+ summaryRow(t("settings.summary.mode"), modeSelect),
3695
+ summaryRow(t("settings.summary.route"), routeText),
3696
+ summaryRow(t("settings.summary.budget"), budgetText),
3697
+ ]);
3698
+
3634
3699
  let children = [
3635
3700
  h("div", { className: "dsh-advisor-head", key: "head" }, [
3636
3701
  h("div", { className: "dsh-advisor-title", key: "title" }, t("settings.title")),
3637
3702
  h("div", { className: "dsh-advisor-desc", key: "desc" }, t("settings.desc")),
3638
3703
  ]),
3639
3704
  errorBanner(),
3640
- modeRow,
3705
+ summary,
3641
3706
  ];
3642
3707
  if (!showForm) {
3643
3708
  children.push(offNotice());
3644
3709
  } else {
3645
3710
  if (draft.mode === "off") children.push(offNotice());
3646
- children.push(group("settings.group.basic", basicBody, "basic"));
3647
- children.push(
3711
+ // 其余设置在折叠里:默认收起,标题上带「有改动」徽标。
3712
+ let moreBody = [
3713
+ // 首屏摘要里的模式下拉是紧凑版;展开「更多设置」后仍保留带说明的完整行。
3714
+ modeRow,
3715
+ group("settings.group.basic", basicBody, "basic"),
3648
3716
  disclosure(
3649
3717
  "advanced",
3650
3718
  t("settings.group.advanced"),
@@ -3655,8 +3723,6 @@ window.__ModuleLoader__.load({
3655
3723
  setAdvancedOpen(!advancedOpen);
3656
3724
  },
3657
3725
  ),
3658
- );
3659
- children.push(
3660
3726
  disclosure(
3661
3727
  "status",
3662
3728
  t("settings.group.status"),
@@ -3667,6 +3733,20 @@ window.__ModuleLoader__.load({
3667
3733
  setStatusOpen(!statusOpen);
3668
3734
  },
3669
3735
  ),
3736
+ ];
3737
+ children.push(
3738
+ disclosure(
3739
+ "more",
3740
+ t("settings.group.more"),
3741
+ // 这里不放「高级项改了几处」的数字:对「更多设置」这个层级没意义,
3742
+ // 容易被读成「还有 13 项没看」。
3743
+ "",
3744
+ moreBody,
3745
+ moreOpen,
3746
+ function toggleMore() {
3747
+ setMoreOpen(!moreOpen);
3748
+ },
3749
+ ),
3670
3750
  );
3671
3751
  }
3672
3752
  children.push(noticeNode);
@@ -3814,7 +3894,8 @@ window.__ModuleLoader__.load({
3814
3894
  "settings.group.money": "单价",
3815
3895
  "settings.group.generation": "生成参数",
3816
3896
  "settings.group.delivery": "投递与行为",
3817
- "settings.group.more": "更多",
3897
+ // 「更多设置」这个折叠标题不在 LOCALE_EXTRA 里重复定义:同名键两处取值不同时,
3898
+ // 后合并的会赢,之前就出现了「内嵌字典写更多设置、实际渲染成更多」的怪象。
3818
3899
  "settings.group.status": "状态与诊断",
3819
3900
  "settings.basic.budgetHint":
3820
3901
  "0 = 不限;默认 0,范围 0–10000(按当前币种)。切换币种会按汇率折算;更细的限额在高级设置里。",
@@ -3976,7 +4057,7 @@ window.__ModuleLoader__.load({
3976
4057
  "settings.group.money": "Prices",
3977
4058
  "settings.group.generation": "Generation",
3978
4059
  "settings.group.delivery": "Delivery & behavior",
3979
- "settings.group.more": "More",
4060
+ // 同上:不在 LOCALE_EXTRA 里重复定义「更多设置」的英文名。
3980
4061
  "settings.group.status": "Status & diagnostics",
3981
4062
  "settings.basic.budgetHint":
3982
4063
  "0 = unlimited; default 0, range 0–10000. Finer limits are under Advanced.",
@@ -4415,12 +4496,13 @@ window.__ModuleLoader__.load({
4415
4496
  // 设置页 → 通用:顾问的模式、路由、预算、隐私与状态摘要。
4416
4497
  ctx.effect(
4417
4498
  () =>
4418
- ctx.slots.inject("settings.general.item", () =>
4499
+ ctx.slots.inject("settings.section", () =>
4419
4500
  ctx.slots.register(
4420
4501
  {
4421
- name: "settings.general.item",
4502
+ name: "settings.section",
4422
4503
  id: "advisor",
4423
- order: 880,
4504
+ order: 92,
4505
+ label: () => t("settings.nav"),
4424
4506
  locale: NS,
4425
4507
  // 同时注入 apply 里绑定的 t:宿主没给 props.t 时也不会退化成裸 key。
4426
4508
  inject: () => ({ api: settingsApi, t: t }),
@@ -0,0 +1,422 @@
1
+ // @ts-check
2
+ // 决策日志:记录**每个回合**「有没有徵询、为什么没徵询、徵询后用户怎么反应」。
3
+ //
4
+ // 为什么单独一个文件而不是并进 usage.jsonl:用途不同。usage 是**钱的账本**(一次徵询一行,
5
+ // 有 token 与成本);decisions 是**策略的证据**(一个回合一行,没有徵询的回合也要记),
6
+ // 用来事后回答「该徵询的时候有没有徵询」。两件事混在一起会让两边都难查。
7
+ //
8
+ // 落盘:`<dataRoot>/advisor/decisions.jsonl`,只追加;超过上限时滚动重命名(保留一份历史)。
9
+ import { mkdir, readFile, rename, stat, writeFile } from "node:fs/promises";
10
+ import { join } from "node:path";
11
+
12
+ import { signalsOf } from "./adoption.js";
13
+ import { LEDGER_DIR } from "./ledger.js";
14
+ import { textOf, toolCallsOf } from "./transcript.js";
15
+
16
+ /** 决策日志文件名(与 usage.jsonl / advice.jsonl 同目录)。 */
17
+ export const DECISIONS_FILE = "decisions.jsonl";
18
+ /** 滚动阈值:与账本一致,超过就改名保留一份。 */
19
+ export const DECISIONS_MAX_BYTES = 2 * 1024 * 1024;
20
+
21
+ /**
22
+ * 没徵询时的原因码。**从主模型视角分类**,而不是按内部函数名:
23
+ * 复盘时要回答的是「这一回合本该问吗」,所以分桶要能对应到「机会成本」。
24
+ * @typedef {"skipped-disabled"|"skipped-not-configured"|"skipped-no-route"|"skipped-empty"|"skipped-budget"|"skipped-limit"|"skipped-immune"|"skipped-duplicate"|"skipped-needs-confirmation"|"skipped-not-requested"|"skipped-aborted"|"skipped-blocked"|"skipped-other"} SkipCode
25
+ */
26
+
27
+ /** 原因文本 → 原因码。宿主侧的跳过原因是人话,这里用模式匹配归到稳定的小集合。 */
28
+ /** @type {Array<[RegExp, SkipCode]>} */
29
+ const SKIP_PATTERNS = [
30
+ [/已关闭|disabled/iu, "skipped-disabled"],
31
+ [/没配置|未配置|not.?configured/iu, "skipped-not-configured"],
32
+ [/没有可用.*路由|no.?route/iu, "skipped-no-route"],
33
+ [/还没有可发送|empty.?transcript/iu, "skipped-empty"],
34
+ [/免疫窗口|immune/iu, "skipped-immune"],
35
+ [/重复建议|duplicate/iu, "skipped-duplicate"],
36
+ [/投递上限|会话上限|session.?cap/iu, "skipped-limit"],
37
+ [/预算|额度|budget|quota/iu, "skipped-budget"],
38
+ [/确认|confirm/iu, "skipped-needs-confirmation"],
39
+ // finishTurn 在非正常结束时会写「回合被中断 / 被阻塞」,
40
+ // 不加这两条就会归到 skipped-other(真实日志里踩到过)。
41
+ [/中断|abort/iu, "skipped-aborted"],
42
+ [/阻塞|blocked/iu, "skipped-blocked"],
43
+ ];
44
+
45
+ /**
46
+ * 把跳过原因归到稳定原因码。
47
+ * @param {string} [reason] 宿主给的跳过原因(人话)
48
+ * @returns {SkipCode}
49
+ */
50
+ export function classifySkip(reason) {
51
+ const text = typeof reason === "string" ? reason.trim() : "";
52
+ if (text === "") return "skipped-not-requested";
53
+ for (const [pattern, code] of SKIP_PATTERNS) {
54
+ if (pattern.test(text)) return code;
55
+ }
56
+ return "skipped-other";
57
+ }
58
+
59
+ /**
60
+ * 回合特征:用来给「该不该徵询」分桶的、可用不变量化的东西。
61
+ * @param {{ answerChars?: number, toolCalls?: number, hadError?: boolean }} input
62
+ * @returns {{ answerChars: number, toolCalls: number, hadError: boolean, longAnswer: boolean, usedTools: boolean }}
63
+ */
64
+ export function turnFeatures(input) {
65
+ const answerChars = Number.isFinite(input?.answerChars) ? Number(input.answerChars) : 0;
66
+ const toolCalls = Number.isFinite(input?.toolCalls) ? Number(input.toolCalls) : 0;
67
+ return {
68
+ answerChars,
69
+ toolCalls,
70
+ hadError: input?.hadError === true,
71
+ // 分桶阈值集中在这里,复盘脚本与日志用的是同一个口径。
72
+ longAnswer: answerChars >= 800,
73
+ usedTools: toolCalls > 0,
74
+ };
75
+ }
76
+
77
+ /**
78
+ * 组装一行决策记录。字段刻意保持扁平,方便 `jq` 直接查。
79
+ * @param {{
80
+ * at?: string, sessionId: string, turn: number, endKind?: string,
81
+ * features?: { answerChars?: number, toolCalls?: number, hadError?: boolean },
82
+ * advice?: { adviceId?: string, severity?: string, trigger?: string, costUsd?: number },
83
+ * skipReason?: string,
84
+ * }} input
85
+ * @returns {any}
86
+ */
87
+ export function buildDecision(input) {
88
+ const advice = input.advice;
89
+ const consulted = advice !== undefined && advice !== null;
90
+ const endKind = input.endKind ?? "completed";
91
+ // 结束原因本身就是最可靠的原因码来源;不要把它降级成「从人话里猜」。
92
+ const endKindCode =
93
+ endKind === "aborted" ? "skipped-aborted" : endKind === "blocked" ? "skipped-blocked" : null;
94
+ return {
95
+ at: input.at ?? new Date().toISOString(),
96
+ sessionId: input.sessionId,
97
+ turn: input.turn,
98
+ endKind,
99
+ consulted,
100
+ // 没徵询时给出原因码,复盘时先看这一列。
101
+ skipCode: consulted ? null : (endKindCode ?? classifySkip(input.skipReason)),
102
+ skipReason: consulted ? null : (input.skipReason ?? ""),
103
+ ...turnFeatures(input.features ?? {}),
104
+ adviceId: advice?.adviceId ?? null,
105
+ severity: advice?.severity ?? null,
106
+ trigger: advice?.trigger ?? null,
107
+ costUsd: typeof advice?.costUsd === "number" ? advice.costUsd : null,
108
+ // 由下一回合回填:用户是照建议做了、还是自己另打了内容、还是什么都没做。
109
+ outcome: null,
110
+ };
111
+ }
112
+
113
+ /**
114
+ * 判定上一回合建议的下场。只看**下一条用户消息**:
115
+ * 建议里出现过的可追踪信号(路径、反引号命令、证据 ref)命中就算 accepted,
116
+ * 用户发了别的内容算 user-typed-other,一直没有新消息算 no-action。
117
+ * @param {{ adviceText?: string, signals?: string[] }} advice
118
+ * @param {string} nextUserText 下一回合用户输入
119
+ * @returns {"accepted"|"user-typed-other"}
120
+ */
121
+ export function outcomeOf(advice, nextUserText) {
122
+ const text = typeof nextUserText === "string" ? nextUserText : "";
123
+ if (text.trim() === "") return "user-typed-other";
124
+ const signals = Array.isArray(advice?.signals) ? advice.signals : [];
125
+ for (const signal of signals) {
126
+ if (typeof signal === "string" && signal.length >= 3 && text.includes(signal))
127
+ return "accepted";
128
+ }
129
+ // 没有信号可追踪时退化为「用户是否在说同一件事」:给不出结论就算另打字。
130
+ return "user-typed-other";
131
+ }
132
+
133
+ /** 分桶键:把回合特征压成有限几个桶,复盘时直接出交叉表。 */
134
+ /** @param {any} record @returns {string} */
135
+ export function bucketOf(record) {
136
+ const length = record?.longAnswer === true ? "长回答" : "短回答";
137
+ const tools = record?.usedTools === true ? "有工具" : "无工具";
138
+ const error = record?.hadError === true ? "有报错" : "无报错";
139
+ return `${length}/${tools}/${error}`;
140
+ }
141
+
142
+ /**
143
+ * 复盘统计。
144
+ * @param {any[]} records
145
+ * @returns {any}
146
+ */
147
+ export function summarize(records) {
148
+ const list = Array.isArray(records)
149
+ ? records.filter((item) => item && typeof item === "object")
150
+ : [];
151
+ /** @type {Map<string, { turns: number, consulted: number, accepted: number, ignored: number, noAction: number }>} */
152
+ const buckets = new Map();
153
+ let consulted = 0;
154
+ let accepted = 0;
155
+ let ignored = 0;
156
+ let noAction = 0;
157
+ /** @type {Record<string, number>} */
158
+ const skipCodes = {};
159
+ const missed = [];
160
+ const overConsulted = [];
161
+
162
+ for (const record of list) {
163
+ const bucket = bucketOf(record);
164
+ const entry = buckets.get(bucket) ?? {
165
+ turns: 0,
166
+ consulted: 0,
167
+ accepted: 0,
168
+ ignored: 0,
169
+ noAction: 0,
170
+ };
171
+ entry.turns += 1;
172
+ if (record.consulted === true) {
173
+ consulted += 1;
174
+ entry.consulted += 1;
175
+ if (record.outcome === "accepted") {
176
+ accepted += 1;
177
+ entry.accepted += 1;
178
+ } else if (record.outcome === "user-typed-other") {
179
+ ignored += 1;
180
+ entry.ignored += 1;
181
+ overConsulted.push(record);
182
+ } else if (record.outcome === "no-action") {
183
+ noAction += 1;
184
+ entry.noAction += 1;
185
+ }
186
+ } else {
187
+ const code = typeof record.skipCode === "string" ? record.skipCode : "skipped-other";
188
+ skipCodes[code] = (skipCodes[code] ?? 0) + 1;
189
+ // 疑似漏徵询:这一回合有工具、回答也不短,却没有徵询。
190
+ if (record.usedTools === true && record.longAnswer === true && record.hadError !== true) {
191
+ missed.push(record);
192
+ }
193
+ }
194
+ buckets.set(bucket, entry);
195
+ }
196
+
197
+ const turns = list.length;
198
+ return {
199
+ turns,
200
+ consulted,
201
+ consultRate: turns === 0 ? 0 : consulted / turns,
202
+ accepted,
203
+ ignored,
204
+ noAction,
205
+ // 采纳率只对「已经出结果」的徵询算,未回填的不进分母。
206
+ acceptRate: accepted + ignored === 0 ? null : accepted / (accepted + ignored),
207
+ skipCodes,
208
+ buckets: [...buckets.entries()]
209
+ .map(([bucket, value]) => ({ bucket, ...value }))
210
+ .sort((a, b) => b.turns - a.turns),
211
+ // 两类可疑样本:各留最近 5 条,够看模式就行。
212
+ missed: missed.slice(-5),
213
+ overConsulted: overConsulted.slice(-5),
214
+ };
215
+ }
216
+
217
+ /**
218
+ * 读决策日志(一行一条;坏行跳过,不让一行脏数据毁掉整份复盘)。
219
+ * @param {string} path
220
+ * @returns {Promise<any[]>}
221
+ */
222
+ export async function readDecisions(path) {
223
+ const text = await readFile(path, "utf8").catch(() => "");
224
+ /** @type {any[]} */
225
+ const out = [];
226
+ for (const line of text.split("\n")) {
227
+ if (line.trim() === "") continue;
228
+ try {
229
+ const parsed = JSON.parse(line);
230
+ if (parsed && typeof parsed === "object") out.push(parsed);
231
+ } catch (_error) {
232
+ /* 跳过坏行 */
233
+ }
234
+ }
235
+ return out;
236
+ }
237
+
238
+ /**
239
+ * 决策日志落盘器:只追加,超大时滚动。
240
+ * @param {{ home: string, logger?: any }} options
241
+ */
242
+ export function createDecisionLog(options) {
243
+ const dir = join(options.home, LEDGER_DIR);
244
+ const path = join(dir, DECISIONS_FILE);
245
+
246
+ return {
247
+ path,
248
+
249
+ /**
250
+ * 追加一行。
251
+ * @param {any} record
252
+ * @returns {Promise<void>}
253
+ */
254
+ async append(record) {
255
+ try {
256
+ await mkdir(dir, { recursive: true });
257
+ const info = await stat(path).catch(() => undefined);
258
+ if (info && info.size > DECISIONS_MAX_BYTES) {
259
+ await rename(path, `${path}.1`).catch(() => undefined);
260
+ }
261
+ const existing =
262
+ info && info.size <= DECISIONS_MAX_BYTES
263
+ ? await readFile(path, "utf8").catch(() => "")
264
+ : "";
265
+ await writeFile(path, `${existing}${JSON.stringify(record)}\n`, "utf8");
266
+ } catch (error) {
267
+ options.logger?.warn?.(`[advisor] 写决策日志失败:${String(error)}`);
268
+ }
269
+ },
270
+
271
+ /**
272
+ * 回填上一回合的 outcome(改最后一条匹配记录)。
273
+ * 日志是追加型;回填用「重写整份文件」实现,文件本身很小,且只在收尾时发生。
274
+ * @param {string} sessionId
275
+ * @param {number} turn
276
+ * @param {string} outcome
277
+ * @returns {Promise<boolean>} 是否真的改到了
278
+ */
279
+ async backfillOutcome(sessionId, turn, outcome) {
280
+ try {
281
+ const records = await readDecisions(path);
282
+ let changed = false;
283
+ for (let index = records.length - 1; index >= 0; index -= 1) {
284
+ const record = records[index];
285
+ if (record?.sessionId === sessionId && record?.turn === turn) {
286
+ if (record.outcome === outcome) return true;
287
+ record.outcome = outcome;
288
+ changed = true;
289
+ break;
290
+ }
291
+ }
292
+ if (!changed) return false;
293
+ await writeFile(
294
+ path,
295
+ `${records.map((item) => JSON.stringify(item)).join("\n")}\n`,
296
+ "utf8",
297
+ );
298
+ return true;
299
+ } catch (error) {
300
+ options.logger?.warn?.(`[advisor] 回填决策日志失败:${String(error)}`);
301
+ return false;
302
+ }
303
+ },
304
+ };
305
+ }
306
+
307
+ /**
308
+ * 回合跟踪器:把「事件 → 回合特征 → 决策行 → outcome 回填」这条链路从 service 里拆出来,
309
+ * 这样它可以脱离宿主包单独测试(service.js 依赖 @deepseek-ai/*,在单测环境里导入不了)。
310
+ * @param {{ log: ReturnType<typeof createDecisionLog>, now?: () => number }} options
311
+ */
312
+ export function createDecisionTracker(options) {
313
+ const log = options.log;
314
+ /** @type {Map<string, { turn: number, answerChars: number, toolCalls: number, hadError: boolean }>} */
315
+ const stats = new Map();
316
+ /** @type {Map<string, any>} */
317
+ const advice = new Map();
318
+ /** @type {Map<string, { turn: number, signals: string[] }>} */
319
+ const pending = new Map();
320
+
321
+ return {
322
+ /**
323
+ * 回合开始:重置本回合统计。
324
+ * @param {string} sessionId
325
+ * @param {number} turn
326
+ */
327
+ startTurn(sessionId, turn) {
328
+ stats.set(sessionId, { turn, answerChars: 0, toolCalls: 0, hadError: false });
329
+ },
330
+
331
+ /**
332
+ * 本回合确实徵询过时调用(由 runAdvisor 写入)。
333
+ * @param {string} sessionId
334
+ * @param {any} value
335
+ */
336
+ noteAdvice(sessionId, value) {
337
+ advice.set(sessionId, value);
338
+ },
339
+
340
+ /**
341
+ * 累计事件特征;收到用户消息时回填上一条决策的 outcome。
342
+ * @param {string} sessionId
343
+ * @param {any} event
344
+ * @returns {{ backfilled: { turn: number, outcome: string } | null }}
345
+ */
346
+ track(sessionId, event) {
347
+ const type = event?.type;
348
+ if (type === "assistant/message") {
349
+ const message = event?.data?.message ?? event?.data;
350
+ const current = stats.get(sessionId);
351
+ if (current) {
352
+ current.answerChars += textOf(message).length;
353
+ current.toolCalls += toolCallsOf(message).length;
354
+ }
355
+ return { backfilled: null };
356
+ }
357
+ if (type === "tools/execute") {
358
+ const current = stats.get(sessionId);
359
+ if (current) current.toolCalls += 1;
360
+ return { backfilled: null };
361
+ }
362
+ if (type === "agent/error" || type === "agent/request-error") {
363
+ const current = stats.get(sessionId);
364
+ if (current) current.hadError = true;
365
+ return { backfilled: null };
366
+ }
367
+ if (type !== "user/message") return { backfilled: null };
368
+
369
+ const waiting = pending.get(sessionId);
370
+ if (!waiting) return { backfilled: null };
371
+ const text = textOf(event?.data?.message ?? event?.data);
372
+ if (text === "") return { backfilled: null };
373
+ pending.delete(sessionId);
374
+ const outcome = outcomeOf({ signals: waiting.signals }, text);
375
+ void log.backfillOutcome(sessionId, waiting.turn, outcome);
376
+ return { backfilled: { turn: waiting.turn, outcome } };
377
+ },
378
+
379
+ /**
380
+ * 回合结束:写一行决策。
381
+ * @param {{ sessionId: string, turn: number, endKind?: string, skipReason?: string, fallbackReason?: string }} input
382
+ * @returns {Promise<any>} 写下的记录
383
+ */
384
+ async finishTurn(input) {
385
+ const current = stats.get(input.sessionId);
386
+ const turn =
387
+ typeof current?.turn === "number" && Number.isFinite(current.turn)
388
+ ? current.turn
389
+ : input.turn;
390
+ const usedAdvice = advice.get(input.sessionId);
391
+ advice.delete(input.sessionId);
392
+ const endKind = input.endKind ?? "completed";
393
+ const record = buildDecision({
394
+ sessionId: input.sessionId,
395
+ turn,
396
+ endKind,
397
+ features: {
398
+ answerChars: current?.answerChars ?? 0,
399
+ toolCalls: current?.toolCalls ?? 0,
400
+ hadError:
401
+ current?.hadError === true || (endKind !== "completed" && endKind !== "aborted"),
402
+ },
403
+ advice: usedAdvice,
404
+ // 非正常结束优先记结束原因,比「还没请示顾问」更有信息量。
405
+ skipReason:
406
+ endKind === "aborted"
407
+ ? "回合被中断"
408
+ : endKind === "blocked"
409
+ ? "回合被阻塞"
410
+ : (input.skipReason ?? input.fallbackReason),
411
+ });
412
+ if (record.consulted && usedAdvice?.adviceText) {
413
+ pending.set(input.sessionId, {
414
+ turn,
415
+ signals: signalsOf({ advice: usedAdvice.adviceText }),
416
+ });
417
+ }
418
+ await log.append(record);
419
+ return record;
420
+ },
421
+ };
422
+ }
package/lib/service.js CHANGED
@@ -20,6 +20,7 @@ import { applyAnchorVerdict, buildIndex, verifyAnchors } from "./anchors.js";
20
20
  import { checkPool, createBudgetPool } from "./budget.js";
21
21
  import { callAdvisor } from "./call.js";
22
22
  import { checkAllowlist, effectivePrice } from "./catalog.js";
23
+ import { createDecisionLog, createDecisionTracker } from "./decisions.js";
23
24
  import {
24
25
  checkBudget,
25
26
  estimateCostUsd,
@@ -145,6 +146,10 @@ export class AdvisorService extends TypertRemoteService {
145
146
  this.logger = ctx?.logger ?? console;
146
147
  this.dataRoot = resolveDataRoot(this.config);
147
148
  this.ledger = createLedger({ home: this.dataRoot, logger: this.logger });
149
+ // 决策日志:一个回合一行,回答「该徵询的时候有没有徵询」,与钱的账本分开。
150
+ this.decisions = createDecisionLog({ home: this.dataRoot, logger: this.logger });
151
+ // 回合跟踪器:事件 → 特征 → 决策行 → outcome 回填(逻辑在 decisions.js,可单测)。
152
+ this.decisionTracker = createDecisionTracker({ log: this.decisions });
148
153
  this.pool = createBudgetPool({ home: this.dataRoot, logger: this.logger });
149
154
  void this.ledger.ready();
150
155
  /** @type {{ at: number, value: any }} */
@@ -813,6 +818,17 @@ export class AdvisorService extends TypertRemoteService {
813
818
  };
814
819
  this.lastResult = result;
815
820
 
821
+ // 决策日志:本回合确实徵询了,记下结果(回合结束时消费,用来算徵询率与采纳率)。
822
+ if (this.lastResult === result && result.status === "reviewed") {
823
+ this.decisionTracker.noteAdvice(sessionId, {
824
+ adviceId,
825
+ severity: result.severity,
826
+ trigger,
827
+ costUsd,
828
+ adviceText: result.advice,
829
+ });
830
+ }
831
+
816
832
  // 落一条 plugin record:turnTail 的「顾问线」与 /advisor report 都读它(不占模型可见 surface)。
817
833
  try {
818
834
  appendPluginRecord(session, ADVICE_RECORD, {
@@ -1272,6 +1288,10 @@ export class AdvisorService extends TypertRemoteService {
1272
1288
  */
1273
1289
  handleSessionEvent(session, event) {
1274
1290
  const sessionId = typeof session?.id === "string" ? session.id : "";
1291
+ // ---- 决策日志:回合特征与 outcome 回填(与徵询逻辑无关,只做记录)----
1292
+ if (sessionId !== "" && !isSubagentSession(session)) {
1293
+ this.decisionTracker.track(sessionId, event);
1294
+ }
1275
1295
  if (sessionId !== "" && event?.type === "turn/start") {
1276
1296
  // 用事件里的**绝对回合号**,不要自己累计:会话可能早于插件加载就已有多个回合,
1277
1297
  // 累计值会和 turnTail 的 props.turn 对不上,顾问线就永远不显示(真机踩过)。
@@ -1282,6 +1302,7 @@ export class AdvisorService extends TypertRemoteService {
1282
1302
  : (this.turnOf.get(sessionId) ?? 0) + 1;
1283
1303
  this.turnOf.set(sessionId, next);
1284
1304
  this.ledger.resetTurn(sessionId, next);
1305
+ this.decisionTracker.startTurn(sessionId, next);
1285
1306
  return;
1286
1307
  }
1287
1308
  if (event?.type !== "turn/end") return;
@@ -1289,8 +1310,9 @@ export class AdvisorService extends TypertRemoteService {
1289
1310
  if (sessionId !== "" && Number.isSafeInteger(endTurn) && endTurn > 0) {
1290
1311
  this.turnOf.set(sessionId, endTurn);
1291
1312
  }
1292
- if (event?.data?.reason?.kind !== "completed") return;
1293
1313
  if (isSubagentSession(session)) return;
1314
+ void this.writeDecision(session, event?.data?.reason?.kind ?? "completed");
1315
+ if (event?.data?.reason?.kind !== "completed") return;
1294
1316
  // 重要:不能在事件分发里同步写会话(重入保护),必须异步一拍。
1295
1317
  void (async () => {
1296
1318
  try {
@@ -1314,6 +1336,25 @@ export class AdvisorService extends TypertRemoteService {
1314
1336
  })();
1315
1337
  }
1316
1338
 
1339
+ /**
1340
+ * 回合结束时写一行决策记录(把跟踪器与宿主状态接起来)。
1341
+ * @param {any} session
1342
+ * @param {string} endKind completed | aborted | blocked | …
1343
+ * @returns {Promise<void>}
1344
+ */
1345
+ async writeDecision(session, endKind) {
1346
+ const sessionId = typeof session?.id === "string" ? session.id : "";
1347
+ if (sessionId === "") return;
1348
+ const turn = Number(this.turnOf.get(sessionId)) || 0;
1349
+ if (!Number.isSafeInteger(turn) || turn <= 0) return;
1350
+ await this.decisionTracker.finishTurn({
1351
+ sessionId,
1352
+ turn,
1353
+ endKind,
1354
+ skipReason: this.lastSkip.get(sessionId),
1355
+ });
1356
+ }
1357
+
1317
1358
  // ---- Remote 方法 ------------------------------------------------------
1318
1359
 
1319
1360
  /**
package/locale/en.json CHANGED
@@ -173,7 +173,7 @@
173
173
  "settings.group.money": "Prices",
174
174
  "settings.group.generation": "Generation",
175
175
  "settings.group.delivery": "Delivery & behavior",
176
- "settings.group.more": "More",
176
+ "settings.group.more": "More settings",
177
177
  "settings.group.status": "Status & diagnostics",
178
178
  "settings.basic.budgetHint": "0 = unlimited; default 0, range 0–10000 in the selected currency. Switching currency converts at the rate; finer limits are under Advanced.",
179
179
  "settings.budget.maxCostHint": "Maximum spend per day; 0 = unlimited. Only counted when prices are set.",
@@ -233,6 +233,12 @@
233
233
  "settings.budget.cachePriceSource.settings": "user settings",
234
234
  "settings.budget.cachePriceSource.none": "unset (cache tokens not priced)",
235
235
  "settings.status.cache": "Cache tokens: {read} read / {write} write",
236
- "settings.status.cacheUnpriced": "The ledger has cache tokens, but cache prices are 0: that part is not priced."
236
+ "settings.status.cacheUnpriced": "The ledger has cache tokens, but cache prices are 0: that part is not priced.",
237
+ "settings.nav": "Advisor",
238
+ "settings.summary.mode": "Mode",
239
+ "settings.summary.route": "Route",
240
+ "settings.summary.budget": "Budget",
241
+ "settings.route.unset": "not chosen",
242
+ "settings.budget.unlimited": "Unlimited"
237
243
  }
238
244
  }
package/locale/zh.json CHANGED
@@ -173,7 +173,7 @@
173
173
  "settings.group.money": "单价",
174
174
  "settings.group.generation": "生成参数",
175
175
  "settings.group.delivery": "投递与行为",
176
- "settings.group.more": "更多",
176
+ "settings.group.more": "更多设置",
177
177
  "settings.group.status": "状态与诊断",
178
178
  "settings.basic.budgetHint": "0 = 不限;默认 0,范围 0–10000(按当前币种)。切换币种会按汇率折算;更细的限额在高级设置里。",
179
179
  "settings.budget.maxCostHint": "每天最多花多少钱;0 = 不限。只有填了单价才会计算金额。",
@@ -233,6 +233,12 @@
233
233
  "settings.budget.cachePriceSource.settings": "用户设置",
234
234
  "settings.budget.cachePriceSource.none": "未配置(缓存 token 不计)",
235
235
  "settings.status.cache": "缓存 token:{read} read / {write} write",
236
- "settings.status.cacheUnpriced": "账本里有缓存 token,但缓存单价为 0:缓存部分没有计价。"
236
+ "settings.status.cacheUnpriced": "账本里有缓存 token,但缓存单价为 0:缓存部分没有计价。",
237
+ "settings.nav": "顾问",
238
+ "settings.summary.mode": "模式",
239
+ "settings.summary.route": "路由",
240
+ "settings.summary.budget": "预算",
241
+ "settings.route.unset": "还没选",
242
+ "settings.budget.unlimited": "不限"
237
243
  }
238
244
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kangyishuai/dsh-advisor",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "description": "Pair the main model with a stronger advisor model it consults at key moments: autonomous second opinion, cost ledger, and model picker",
5
5
  "keywords": [
6
6
  "dsh",