@kangyishuai/dsh-next-step 0.3.1 → 0.4.0
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 +20 -13
- package/README.zh-CN.md +23 -15
- package/lib/card-data.js +157 -0
- package/lib/client.js +476 -81
- package/lib/events.js +287 -0
- package/lib/gates.js +27 -6
- package/lib/projection.js +32 -73
- package/lib/prompt.js +225 -55
- package/lib/report.js +557 -0
- package/lib/scheme.js +68 -0
- package/lib/service.js +612 -119
- package/lib/settings.js +68 -8
- package/locale/en.json +22 -2
- package/locale/zh.json +22 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @kangyishuai/dsh-next-step
|
|
2
2
|
|
|
3
|
-
> A next-step decision card for DeepSeek Harness: after
|
|
3
|
+
> A next-step decision card for DeepSeek Harness: after a completed answer that looks worth continuing, a compact card shows where the conversation stands, the question you need to settle, and 1–2 mutually exclusive proposals. Click one and that pill's text — exactly as written on it — is sent as your user message. **How often cards appear is a switch you own** (strict / balanced / eager); when one is withheld, a one-click button reveals the candidate the plugin already computed, with no second model call. It also keeps a **local review log** so the thresholds, the wording and the buttons can be tuned against evidence instead of vibes. Optionally — off by default — a grey ghost hint in the empty composer offers the next prompt, accepted with `Tab` or `→`.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@kangyishuai/dsh-next-step) [](#compatibility) [](./LICENSE)
|
|
6
6
|
|
|
@@ -14,19 +14,22 @@ Unofficial plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/de
|
|
|
14
14
|
|
|
15
15
|
## What it does
|
|
16
16
|
|
|
17
|
-
- **A card
|
|
17
|
+
- **A card when there is something to continue — as often as _you_ want.** When a turn ends normally, the plugin makes one extra model call that asks the model to grade the turn on a three-level scale (`must` / `could` / `no`, with "when in doubt say `could`" written into the prompt). A setting decides which levels are shown: **Strict** (`must` only), **Balanced** (default: `must` + `could`) or **Eager** (everything, including `no` — an experimental calibration mode). The card itself is always computed; the tier only decides whether it is displayed. When it is shown, a decision card is appended below the answer: a one-to-three sentence **summary** of the conversation state (folded to two lines, with an expand/collapse control when it is longer), one **question** that names the decision you have to make, and **1–2 pills** for mutually exclusive directions (one is fine when the next step is obvious — no padding). Each pill carries the exact sentence that will be sent when you click it: **2–20 characters, verb-first, and it must name a concrete object from the conversation** (file, command, flag, version, PR number). Generic pills like “check whether the definition is accurate” are dropped — if none survive, no card is shown at all.
|
|
18
18
|
- **One click is one user message.** Clicking a pill puts that pill's own text into the composer and submits it through the same path as pressing Enter yourself — not by faking a session event. An idle session sends immediately; if a turn is already running, the text is queued exactly like a typed message.
|
|
19
19
|
- **It stays.** Cards and decisions are appended to the session log as plugin records and folded by a session projection, which is the only source of truth. A page reload, a session switch or an app restart brings them back; the client keeps no separate state.
|
|
20
20
|
- **Resolved, not removed.** After you click, the card stays in the transcript but becomes read-only: summary and question remain, the pills are replaced by the one you picked in a selected state (✓ plus its text), followed by a grey “sent” line. Cards from earlier turns are always read-only, so at most one card is interactive at a time. The ✕ in a card's corner dismisses it without sending anything.
|
|
21
21
|
- **Ghost hint in the composer (off by default).** The same model call also produces one next prompt. With the ghost face enabled, an empty idle composer shows it as grey, placeholder-style text. `Tab` or `→` accepts it into the draft (undoable with `Ctrl+Z`), `Esc` clears the current suggestion, typing makes it disappear, and it stays hidden while the composer holds a draft, an attachment, an `@` reference or a slash command. The ghost is not draft content, so pressing Enter on an otherwise empty composer sends nothing.
|
|
22
22
|
- **Two faces, one call.** Card and ghost are produced together by a single model call — turning the ghost on costs no additional requests.
|
|
23
|
+
- **Withheld cards are one click away, and free.** A turn whose card the tier withheld still gets the small “Generate a next-step card” button under the answer. Clicking it **reveals the candidate that was already computed** — no second model call, no 20-second wait. Only a turn that never produced a candidate (the call failed or timed out) actually calls the model again. Clicking that button is also the strongest evidence that the tier withheld something you wanted.
|
|
24
|
+
- **A local review log, so tuning has evidence.** Every eligible turn appends one line to `<dataRoot>/next-step/events.jsonl`: which gate decided, the three-level grade, latency, token usage, what you did with the card afterwards (clicked / dismissed / ignored / typed your own message / revealed it), and whether the card ever entered the viewport. Nothing is uploaded, and your message text is never written — only lengths, delays and how many concrete objects overlapped with a pill. From the settings section you can generate a Markdown report (kept: the latest 20) whose verdict sentences only appear once there are enough data points (80 turns / 25 cards).
|
|
23
25
|
- **Switches that actually stop requests.** `card` (default on) and `ghost` (default off) are separate switches; the global `enabled` switch off means no generation request at all, not just a hidden UI. A pause and a per-session card budget (`maxCardsPerSession`) stop new cards too. Cards already in the log stay readable.
|
|
24
26
|
|
|
25
27
|
## Cost & model calls
|
|
26
28
|
|
|
27
29
|
- One extra model call per trigger, on the model the session's agent is currently using (falling back to the default model selection), billed to your own provider quota.
|
|
28
30
|
- The call times out after 20 s. Other failures, rate limits and malformed JSON are silent: no card, no dialog — only a counter in the plugin's diagnostics. A **timeout or cancellation** is counted separately (the `aborted` counter plus a "Last skipped" reason such as `generation timeout after 20s`), and the generate button then says the generation timed out or was cancelled — so this class stays diagnosable afterwards. Malformed output is dropped without writing a record.
|
|
29
|
-
- When the model
|
|
31
|
+
- When the model grades the turn `no` (or `could`, and your tier is Strict), the candidate is stored but not shown — **the call still happens**: the tier saves UI noise, not tokens. Revealing a withheld candidate later costs nothing (no second call).
|
|
32
|
+
- The review log is a local append-only file that rotates at 2 MB (`events.jsonl` + one `.1` history). It contains no message text; it is on by default and can be switched off in the settings ("Local usage data").
|
|
30
33
|
- No other network access, no telemetry.
|
|
31
34
|
|
|
32
35
|
## Side effects & risks
|
|
@@ -38,7 +41,7 @@ Unofficial plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/de
|
|
|
38
41
|
- **Private host seams.** The card renders through `conversation.chat.turnTail`; state comes from a host session projection read via `useProjection`; click-to-send uses the composer shell (`setDraft` / `submit`, waiting for the draft to settle before submitting); the ghost uses `conversation.input.overlay` and the host's placeholder DOM. These are internal, untyped and unversioned: a DSH upgrade can make the card, the send path or the ghost stop working **silently**. The plugin degrades instead of breaking a session, but after an upgrade run `pnpm probe:runtime` and the smoke suites, and check diagnostics.
|
|
39
42
|
- **The ghost is coupled to the host placeholder DOM**, which is why it ships off by default; if that DOM changes, the hint can simply disappear.
|
|
40
43
|
- **Silent failure is by design.** “No card appeared” is not an error dialog; look at the diagnostics counters before filing a bug. Timeouts and cancellations are the one exception worth knowing: they are labelled rather than lumped into a generic failure, because an unlabelled abort is what made one “no card” incident undiagnosable.
|
|
41
|
-
- **
|
|
44
|
+
- **Writes two things under the data root.** (a) The existing session log gets one card record per generated card — including withheld candidates, so `shown` grows by at most one small record per eligible turn; (b) `<dataRoot>/next-step/events.jsonl` (review log, 2 MB rotation) plus `report-*.md` when you ask for one (the newest 20 are kept, older ones are deleted inside that plugin directory only). **No message text is ever written to the log**, and nothing leaves the machine.
|
|
42
45
|
- **Subagent sessions never get cards**, and only normally completed turns are eligible.
|
|
43
46
|
|
|
44
47
|
## Install
|
|
@@ -73,11 +76,14 @@ Re-run `pnpm pack` + `add` after changing the code. The plugin has a host half,
|
|
|
73
76
|
|
|
74
77
|
Settings → **Next-step suggestions** (its own section now, no longer a row buried in General) has everything you need to control it:
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
The section opens with **three rows** — enable, **card frequency** (strict / balanced / eager, changeable in place) and the card switch — and everything else sits under a **“More settings”** disclosure (collapsed by default):
|
|
80
|
+
|
|
81
|
+
- **Local usage data** — the review log switch (default on).
|
|
82
|
+
- **Ghost hint in the composer** — the second face's switch (default off).
|
|
78
83
|
- **Cadence** — “Pause for 1 hour” / “Resume”.
|
|
79
|
-
- **Per session, at most N cards** — the budget (`maxCardsPerSession`, clamped to 0–1000).
|
|
80
|
-
- **
|
|
84
|
+
- **Per session, at most N cards** — the budget (`maxCardsPerSession`, clamped to 0–1000, default 120). It only counts cards that were _shown_; withheld candidates do not consume it.
|
|
85
|
+
- **Review** — the four numbers that matter (card rate / click-through / ignore rate / misses), a one-line verdict when the sample is big enough, and a **“Generate report”** button that writes `report-YYYYMMDD-HHmmss.md` next to the log.
|
|
86
|
+
- **Diagnostics** — generated (with how many were withheld) / failed / aborted / skipped / in-flight counters, the **reason the last card was skipped** (model judged unnecessary / queued / paused / budget / failure / timeout / cancelled, with the model's own sentence), the last error, the runtime **version + build hash**, and a Refresh button. `nextStep/diagnostics` returns the same `version` / `buildHash` / `buildFiles` / `packagePath`, so a running build can be matched against `dsh plugin list` or the npm tarball without digging through startup logs.
|
|
81
87
|
|
|
82
88
|
Turning the global switch off **hides every dependent row** (card / ghost / pause / budget / diagnostics) and leaves just the switch plus one line of explanation — off means off, nothing looks like it still runs, and re-enabling restores the previous switch values.
|
|
83
89
|
|
|
@@ -115,11 +121,12 @@ The row writes the same `$DSH_HOME/next-step.settings.json` that the host re-rea
|
|
|
115
121
|
|
|
116
122
|
## Compatibility
|
|
117
123
|
|
|
118
|
-
| DSH version | Status
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
| 0.2.2-rc.
|
|
122
|
-
| 0.2.2-rc.
|
|
124
|
+
| DSH version | Status |
|
|
125
|
+
| 0.2.2-rc.3 | **0.4.0** (2026-11-14): the card face becomes tunable and measurable. The model grades a turn on three levels (`must` / `could` / `no`) instead of a boolean, and a setting picks which levels are shown (**strict / balanced (default) / eager**). A withheld card still stores its candidate and one click **reveals** it — no second model call; only a turn without any candidate regenerates. Parsing is tolerant (over-long text is clipped, a bad single option is dropped) with one repair call, so one over-long field can no longer delete a whole card. Every eligible turn appends one line to `<dataRoot>/next-step/events.jsonl` (gate, grade, latency, usage, what you did with the card, whether it entered the viewport; never your message text, local only, can be switched off), and the settings section writes a Markdown report with Wilson 95% intervals that refuses to give verdicts below 80 turns / 25 cards. Three deterministic losses are gone: the budget (30 → 120) only counts _shown_ cards, the short-answer gate now requires "few chars **and** no tool calls", and a bad field no longer voids the card. Settings moved to a 3-row first screen plus a "More settings" disclosure; the settings file is v2 (`schemaVersion` / `cardThreshold` / `telemetry`) and only migrates values equal to the old default. Verified: 169 unit tests + `pnpm probe:runtime` + web `pnpm smoke:next-step` **71/71** (real host, real model calls, including the withheld→reveal path and the event log) + desktop read-only regression. |
|
|
126
|
+
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
127
|
+
| 0.2.2-rc.3 | **0.3.1** (2026-11-14): makes an aborted generation diagnosable. A 20 s timeout or a cancellation used to leave **no trace at all** — no counter, no “Last skipped” entry, no session record — so a “no card appeared” incident was impossible to attribute after the fact. Now aborts increment a separate `aborted` counter (shown in the settings row as “已中止 N”), write a labelled “Last skipped” reason (`generation timeout after 20s` / `cancelled`), stay out of `failed` / `lastError`, and the generate button says “生成超时或被取消,请重试” instead of the generic failure text. Verified: 103 unit tests (4 new) + `pnpm probe:runtime` 72/72 + web `pnpm smoke:next-step` **59/59** (real host + real model call, re-run after the change) + desktop read-only regression **10 PASS + 2 SKIP**; `smoke:next-step` also gained the ability to print the plugin-reported reason and to keep its throwaway `DSH_HOME` when an assertion fails. |
|
|
128
|
+
| 0.2.2-rc.2 | **0.3.0** (2026-11-14): pill labels tightened to 2–20 characters and must name a concrete object (generic pills are dropped), 1–2 options instead of exactly 2, summaries must state checkable facts, two new cheap gates (previous turn errored / answer under 80 characters), ghost hint capped at 150 characters and degraded when it disagrees with the recommended pill; settings moved to their own "Settings → Next-step suggestions" section. Verified: 58 unit tests (50 prompt + 8 gates) + `pnpm probe:runtime` 72/72 + web `pnpm smoke:next-step` **59/59** (real host, real model call). The settings section was also checked on a live desktop build via read-only CDP; the desktop read-only regression reports **10 PASS + 2 SKIP** (the SKIPs are "no card in this session" and "read-only mode does not create cards"); `--deep` card interaction reports **23 PASS + 2 SKIP** (real model call — the one-sentence fixture is blocked by the new "answer under 80 characters" gate, so the run exercises the generate-now fallback, which also verifies that gate). |
|
|
129
|
+
| 0.2.2-rc.1 | Full regression green on 2026-11-11: web composition end-to-end (`pnpm smoke:next-step`: 59 assertions passing, 0 skipped; real host + real model calls, covering WYSIWYG sending, the picked-option echo, the `needed` gate and the force-generate button, and the progressive settings), desktop real-machine `pnpm smoke:next-step-desktop --require --deep` (32 passing + 3 skipped + 0 failing on the pre-release tarball, build `1ba08e8b`; the published 0.2.0 self-reports `version 0.2.0, build ce72c9dd` — the hash covers `package.json`, so the version bump changes it; every skip is a data-dependent branch), 83 unit tests, runtime probe 60/60, and `pnpm gate next-step` green across all four steps. Other DSH versions are not verified. |
|
|
123
130
|
|
|
124
131
|
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 the table as the compatibility statement. After a DSH upgrade run `pnpm probe:runtime`, `pnpm smoke:next-step` and `pnpm smoke:next-step-desktop`, then check the plugin's diagnostics.
|
|
125
132
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @kangyishuai/dsh-next-step
|
|
2
2
|
|
|
3
|
-
> DeepSeek Harness
|
|
3
|
+
> DeepSeek Harness 的「下一步决策卡」:一轮值得继续的回答之后,给一张小卡片,写清对话现状、需要你拍板的问题,以及 1–2 条互斥的下一步建议;点哪一句,就把那句**原样**作为用户消息发出(所见即所发)。**出卡频率由你选**(严格 / 平衡 / 积极);被档位拦下时,最新回答下方有一键按钮可以**揭示已经算好的候选**,不额外调一次模型。它还会在本地记一份**复盘日志**,让阈值、措辞和按钮可以按证据调,而不是凭手感。可选(默认关)在空输入框里给一条灰色幽灵提示,`Tab` / `→` 接受。
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@kangyishuai/dsh-next-step) [](#兼容性) [](./LICENSE)
|
|
6
6
|
|
|
@@ -14,19 +14,22 @@
|
|
|
14
14
|
|
|
15
15
|
## 它做什么
|
|
16
16
|
|
|
17
|
-
-
|
|
17
|
+
- **有得继续就出卡——多频繁由你定。** 一轮正常结束后,插件额外调用一次模型,让模型把这一轮打成三档(`must` / `could` / `no`,提示词里明写「拿不准一律判 `could`」)。设置里的**出卡频率**决定显示哪几档:**严格**(只出 `must`)、**平衡**(默认,`must` + `could`)、**积极**(三档全出,含 `no`,校准用实验档)。卡片内容总是会算出来,档位只决定要不要显示;值得时在回答下方追加一张决策卡——一到三句**现状摘要**(超过两行折叠,带「展开 / 收起」小按钮)、一句点名要你拍板的**提问**,以及 **1–2 粒互斥方向**的胶囊(下一步很明确时就只给一粒,不凑数)。胶囊上就是点击后**原样发出**的那句话:**2–20 字、动词开头、必须含对话里的具体对象**(文件名 / 命令 / 参数 / 版本号 / PR 号)——「检查定义是否准确」这类放到哪一轮都成立的按钮会被直接丢掉,一条都不剩就整卡不出。
|
|
18
18
|
- **点一下就是一条用户消息。** 点胶囊会把它自己那行文本填入输入框,并走和手动回车**同一条提交链**发出——不是伪造会话事件。空闲会话立即发送;如果已有回合在跑,就和你打字一样排进队列。
|
|
19
19
|
- **刷新也不丢。** 卡片和决策以插件记录的形式追加进会话日志,由宿主的 session projection 折叠,这是唯一的数据来源。刷新页面、切换会话、重开应用都还在;客户端不另存状态。
|
|
20
20
|
- **只读保留,不是消失。** 点过之后卡片仍留在对话里,但变成只读:摘要和提问保留,两粒胶囊换成**你点的那一粒的选中态**(✓ + 那句话),后面跟一行灰字「已发出」。更早轮次的卡一律只读,所以任何时刻最多一张卡可交互。卡片右上角的 ✕ 可以收掉这张卡,不发送任何东西。
|
|
21
21
|
- **输入框幽灵提示(默认关)。** 同一次模型调用还会产出一条「下一句提示」。打开 ghost 面后,空且空闲的输入框里会以灰色、和宿主 placeholder 同字号同基线的样子显示它。`Tab` / `→` 接受进草稿(`Ctrl+Z` 可撤销),`Esc` 清除本次建议,开始打字就消失;输入框里有草稿、附件、`@` 引用或斜杠命令时隐藏。幽灵提示**不是草稿内容**,所以空框按 Enter 仍然什么都不会发。
|
|
22
22
|
- **两个面,一次调用。** 卡片和幽灵提示由同一次模型调用一起产出,打开 ghost 不会多花请求。
|
|
23
|
+
- **被拦下的卡一键可得,而且免费。** 被档位拦下的回合照样有「生成下一步建议」按钮;点它**揭示已经算好的候选**——不再调第二次模型、不用等 20 秒。只有这一轮压根没生成过候选(调用失败或超时)时才会真的再调一次。点这个按钮本身也是「档位拦掉了用户想要的卡」最硬的证据。
|
|
24
|
+
- **本地复盘日志,让调参有证据。** 每个合格回合往 `<dataRoot>/next-step/events.jsonl` 追加一行:哪道闸决定的、三档判定、耗时、token、你后来对这张卡做了什么(点了 / 关了 / 无视 / 自己打了下一条 / 揭示了它),以及卡片有没有真的进过视口。不上传,**也从不写你的消息原文**——只留长度、延迟,以及跟胶囊重合了几个具体对象。设置页可以生成一份 Markdown 报告(保留最新 20 份),样本不够时报告只列计数、不给结论(门槛:80 个回合 / 25 张卡)。
|
|
23
25
|
- **开关是真的能停。** `card`(默认开)与 `ghost`(默认关)是分开的两个开关;全局开关关闭后**不再发起生成请求**,不是只把 UI 藏起来。另有暂停和每会话卡片预算(`maxCardsPerSession`)限制新卡。已经写进日志的卡仍然可读。
|
|
24
26
|
|
|
25
27
|
## 成本
|
|
26
28
|
|
|
27
29
|
- 每次触发多一次模型调用,用会话所在智能体当前的模型(取不到时回退到默认模型选择),**占用你自己的 provider 额度**。
|
|
28
30
|
- 这次调用 20 秒超时。其它失败、限流、JSON 不合法都**静默**:不出卡、不弹框,只在插件诊断里加计数。**超时 / 被取消**单独计数(`aborted`,并在「最近跳过」写明 `generation timeout after 20s`),补生成按钮也会显示「生成超时或被取消」,所以这一类事后可诊断。不合法输出直接丢弃,不写记录。
|
|
29
|
-
-
|
|
31
|
+
- 模型判成 `no`(或判 `could` 而你选的是严格档)时不显示卡,但**这次调用已经发生**:档位省的是界面噪音,不是 token。事后揭示也不会再花一次调用。想看模型给出的理由,去设置页诊断里的「最近跳过」。
|
|
32
|
+
- 复盘日志是本机 append-only 文件,2 MB 滚动(`events.jsonl` + 一份 `.1` 历史)。里面没有消息原文;默认开启,可在设置里关掉(「本地采集与复盘数据」)。
|
|
30
33
|
- 除此之外不联网,不上报。
|
|
31
34
|
|
|
32
35
|
## 副作用与风险
|
|
@@ -38,7 +41,7 @@
|
|
|
38
41
|
- **依赖宿主私有 seam。** 卡片渲染走 `conversation.chat.turnTail`;状态来自宿主 session projection(客户端用 `useProjection` 读);点击发送走 composer shell 的 `setDraft` / `submit`(提交前等草稿落定);幽灵提示走 `conversation.input.overlay` 和宿主 placeholder 的 DOM。这些都没有类型、没有版本契约:DSH 升级可能让卡片、发送链或幽灵提示**静默失效**。插件会降级而不是弄坏会话,但升级后请跑 `pnpm probe:runtime`、两个冒烟套件,并看诊断。
|
|
39
42
|
- **幽灵提示和宿主 placeholder DOM 绑在一起**,这也是它默认关的原因;宿主改了那块 DOM,它就只是不显示了。
|
|
40
43
|
- **失败静默是设计。**「没出卡」不是错误弹窗;先看诊断计数再判断是不是 bug。超时与取消是唯一值得单独知道的例外:它们会被标成自己的原因,而不是混进笼统的失败——之前正因为中止无痕,一次「没出卡」完全没法定位。
|
|
41
|
-
-
|
|
44
|
+
- **会在数据根下写两样东西。**(a)现有会话日志里每张生成的卡多一条记录——被抑制的候选也会记(`shown: false`),所以每个合格回合最多多一条小记录;(b)`<dataRoot>/next-step/events.jsonl`(复盘日志,2 MB 滚动),以及你点「生成报告」时的 `report-*.md`(保留最新 20 份,更早的在**这个插件目录内**删除)。**日志里不写消息原文**,也不会有任何东西离开本机。
|
|
42
45
|
- **子代理会话不出卡**,被停止、报错或没有文本的回合同样不出卡。
|
|
43
46
|
|
|
44
47
|
## 安装
|
|
@@ -73,11 +76,14 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-next-step-*.tgz
|
|
|
73
76
|
|
|
74
77
|
设置 → **下一步建议**(独立分节)就是一整页控制项:
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
分节首屏是**三行**(启用 / **出卡频率**(严格 / 平衡 / 积极,可直接切)/ 决策卡开关),其余收进默认收起的 **「更多设置」**:
|
|
80
|
+
|
|
81
|
+
- **本地采集与复盘数据** —— 复盘日志开关(默认开)。
|
|
82
|
+
- **输入框里的幽灵提示** —— 第二个面的开关(默认关)。
|
|
78
83
|
- **生成节奏** —— 「暂停 1 小时」/「恢复生成」。
|
|
79
|
-
- **每会话最多 N 张卡** —— 预算(`maxCardsPerSession`,夹在 0–1000
|
|
80
|
-
-
|
|
84
|
+
- **每会话最多 N 张卡** —— 预算(`maxCardsPerSession`,夹在 0–1000,默认 120)。只统计**出过**的卡,被抑制的候选不占预算。
|
|
85
|
+
- **回顾** —— 四个关键数字(出卡率 / 点击率 / 忽略率 / 漏判)+ 样本够时的一句话判读 + **「生成报告」**按钮,报告写在日志旁边。
|
|
86
|
+
- **诊断** —— 已生成(含未显示数)/ 失败 / 已中止 / 跳过 / 在途计数、**最近一次没出卡的原因**(模型判断不需要 / 排队 / 暂停 / 预算 / 失败 / 超时 / 取消,附模型给的理由)、最近错误、**运行时版本 + 构建哈希**、刷新按钮。`nextStep/diagnostics` 同样返回 `version` / `buildHash` / `buildFiles` / `packagePath` 与 `lastSkip`,所以运行中的构建可以和 `dsh plugin list` 或 npm 上的 tarball 对照,不需要翻启动日志。
|
|
81
87
|
|
|
82
88
|
关闭总开关后,卡片 / 幽灵 / 暂停 / 预算 / 诊断这些依赖项会**整段隐藏**,只留总开关和一行说明——关掉就是关掉,不会让人以为还有东西在跑;重新启用时这些开关的取值都还在。
|
|
83
89
|
|
|
@@ -103,23 +109,25 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-next-step-*.tgz
|
|
|
103
109
|
|
|
104
110
|
- **卡片排在回答下方**(`conversation.chat.turnTail`),不在输入区。答完后它就在最后一条回答下面,不用滚动;更早轮次的卡随对话历史一起滚动(取舍见 ADR 0009 §4)。
|
|
105
111
|
- **有排队消息时不出卡。** 如果你已经排了 2 条以上待发送消息,这一轮就跳过生成(官方 action cards 用同一条规则);插件本身不会排队或代发任何东西。
|
|
106
|
-
-
|
|
112
|
+
- **建议 1–2 条。** 方向必须互斥;下一步很明确时只给一条,不凑数。
|
|
107
113
|
- **`⌘↵` / `Ctrl+↵` 只在「输入框干净 + 会话空闲 + 卡片可交互」时接管。** 其它时候这个组合仍是宿主的 Queue/Steer 互补发送;插件不抢占。
|
|
108
114
|
- **不做跨设备同步。** 卡片和决策只存在生成它的那台机器的本地会话日志里。
|
|
109
115
|
- **子代理会话不出卡**,被中断或没有文本的回合也不出。
|
|
110
116
|
- **幽灵提示只给最新一张卡的下一句**,且只在输入框为空、会话空闲时出现。
|
|
111
|
-
- **卡片文字来自模型。**
|
|
117
|
+
- **卡片文字来自模型。** 插件会校验形状(1–2 条选项、方向互斥、label 2–20 字且含具体对象),超长/空话的单条会被丢掉(必要时先让模型修一次格式),但不改写措辞。
|
|
118
|
+
- **复盘要等样本。** 少于 80 个合格回合或 25 张卡时,报告只列计数并明写「样本不足」——一两天几十条数据得出的结论只会是噪声。
|
|
112
119
|
- **点击发出去的就是按钮文本**,不再有「按钮短、背后另有一段长指令」的隐藏层:旧版本卡片记录里残留的 `text` 字段会被忽略。
|
|
113
120
|
|
|
114
121
|

|
|
115
122
|
|
|
116
123
|
## 兼容性
|
|
117
124
|
|
|
118
|
-
| DSH 版本
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
| 0.2.2-rc.
|
|
122
|
-
| 0.2.2-rc.
|
|
125
|
+
| DSH 版本 | 状态 |
|
|
126
|
+
| 0.2.2-rc.3 | **0.4.0**(2026-11-14):卡片这一面变成**可调**且**可度量**。模型不再用一个 boolean,而是把回合打成三档(`must` / `could` / `no`),设置里选出卡频率(**严格 / 平衡(默认)/ 积极**)。被档位拦下的卡仍会存下候选,点一下**揭示**它——不再第二次调模型;只有压根没有候选的回合才真的重新生成。解析变宽容(超长文本截断、单条不合格只丢这一条)+ 一次修复调用,一个字段超长不再让整张卡消失。每个合格回合往 `<dataRoot>/next-step/events.jsonl` 追加一行(闸门、三档判定、耗时、token、你后来对卡做了什么、有没有进过视口;不写消息原文、只在本机、可关),设置页还能生成带 Wilson 95% 区间的 Markdown 报告,样本少于 80 回合 / 25 张卡时拒绝给判读。三处确定性丢失也修了:预算(30 → 120)只统计**出过**的卡、短答闸改成「字数少**且**没有工具调用」、单个字段超长不再废掉整张卡。设置页收敛成首屏 3 行 +「更多设置」折叠;设置文件升级到 v2(`schemaVersion` / `cardThreshold` / `telemetry`),只迁移等于旧默认值的字段。验证:单测 169 项 + `pnpm probe:runtime` + web `pnpm smoke:next-step` **71/71**(真实宿主、真实模型调用,含「抑制 → 揭示」链路与事件文件)+ 桌面只读回归。 |
|
|
127
|
+
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
128
|
+
| 0.2.2-rc.3 | **0.3.1**(2026-11-14):让被中止的生成可诊断。此前 20 秒超时或被取消**完全无痕**——不计数、不写「最近跳过」、也不落会话日志——所以一次「卡片没出来」事后无法归因。现在中止会计入独立的 `aborted` 计数(设置页显示「已中止 N」)、写带标签的「最近跳过」原因(`generation timeout after 20s` / `cancelled`)、不再混进 `failed` / `lastError`,补生成按钮的文案也从笼统的失败文案改为「生成超时或被取消,请重试」。已验证:103 项单测(新增 4)+ `pnpm probe:runtime` 72/72 + web `pnpm smoke:next-step` **59/59**(真实宿主 + 真实模型调用,改动后重跑)+ 桌面只读回归 **10 PASS + 2 SKIP**;`smoke:next-step` 同时补了「打印插件自报原因」与「断言失败自动保留临时 `DSH_HOME`」。 |
|
|
129
|
+
| 0.2.2-rc.2 | **0.3.0**(2026-11-14):胶囊文案收紧到 2–20 字且必须含具体对象(泛化按钮直接丢弃)、选项 1–2 条、摘要要求写事实、新增「上轮报错 / 回答 < 80 字」两道便宜闸、幽灵提示 150 字上限 + 与推荐项一致性退化;设置搬到「设置 → 下一步建议」分节。已验证:单测 58(prompt 50 + gates 8)+ `pnpm probe:runtime` 72/72 + web `pnpm smoke:next-step` **59/59**(真实宿主 + 真实模型调用)。设置分节另有真机只读 CDP 核验;桌面只读回归 **10 PASS + 2 SKIP**(SKIP 是「当前会话没有决策卡」与「只读模式不造卡」);`--deep` 造卡交互 **23 PASS + 2 SKIP**(真实模型调用;一句话提示词会被「回答 < 80 字」闸挡住,走的是补生成按钮那条兜底,顺带验证了闸)。 |
|
|
130
|
+
| 0.2.2-rc.1 | 2026-11-11 全量回归通过:web 组合端到端(`pnpm smoke:next-step`:59 项断言全部通过 + 0 SKIP;真实宿主 + 真实模型调用,覆盖 WYSIWYG 发送、点后回显、`needed` 门控与补生成按钮、设置渐进披露)、桌面真机 `pnpm smoke:next-step-desktop --require --deep`(32 PASS + 3 SKIP + 0 FAIL,发版前 tarball 构建 `1ba08e8b`;发布后 0.2.0 只读自证 20 PASS + 2 SKIP,诊断 `版本 0.2.0 · 构建 ce72c9dd`,哈希含 `package.json` 版本故与发版前不同)、单测 83 项、宿主探针 60/60、`pnpm gate next-step` 四步全绿。其他 DSH 版本未验证。 |
|
|
123
131
|
|
|
124
132
|
插件不声明 `engines.dsh`,也不声明 `@deepseek-ai/*` 的 peer 范围:DSH 还在预发布阶段,预发布版本的 semver 范围不可靠(见 [ADR 0005](../../docs/adr/0005-dsh-version-compatibility.md))。以这张表为准。DSH 升级后跑 `pnpm probe:runtime`、`pnpm smoke:next-step`、`pnpm smoke:next-step-desktop`,并看插件诊断。
|
|
125
133
|
|
package/lib/card-data.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// 卡片/决策/揭示记录的**纯校验与归一化**:不 import 宿主包,可以直接单测。
|
|
3
|
+
//
|
|
4
|
+
// 为什么从 projection.js 抽出来:投影模块要 import `@deepseek-ai/dsh-session`(运行时由宿主解析),
|
|
5
|
+
// 在 `node --test` 里导入不了,于是「旧记录怎么读」「隐藏/显示的判定」这些最容易出错的逻辑
|
|
6
|
+
// 一直没有单测。把纯函数搬到这里之后,投影只负责折叠事件。
|
|
7
|
+
|
|
8
|
+
import { isCardTier, isCardValue } from "./scheme.js";
|
|
9
|
+
|
|
10
|
+
/** 卡片记录类型(一轮一张,`shown:false` 表示被档位抑制的候选)。 */
|
|
11
|
+
export const CARD_RECORD = "plugin:next-step/card";
|
|
12
|
+
/** 揭示记录类型(用户要求显示被抑制的候选)。 */
|
|
13
|
+
export const REVEAL_RECORD = "plugin:next-step/reveal";
|
|
14
|
+
/** 决策记录类型(点了 / 关了)。 */
|
|
15
|
+
export const DECISION_RECORD = "plugin:next-step/decision";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 一条 option 是否合法(label 既是按钮文案,也是点击后原样发出的用户消息)。
|
|
19
|
+
* @param {any} option
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
export function isOption(option) {
|
|
23
|
+
return (
|
|
24
|
+
option !== null &&
|
|
25
|
+
typeof option === "object" &&
|
|
26
|
+
typeof option.stance === "string" &&
|
|
27
|
+
option.stance.trim() !== "" &&
|
|
28
|
+
typeof option.label === "string" &&
|
|
29
|
+
option.label.trim() !== ""
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 卡片记录的结构校验(**宽容**:旧记录没有 value/shown/tier/promptVersion 也算合法,
|
|
35
|
+
* 由 readCard 补默认值;这里只保证渲染与统计用得到的字段可用)。
|
|
36
|
+
* @param {any} data
|
|
37
|
+
* @returns {boolean}
|
|
38
|
+
*/
|
|
39
|
+
export function isCardData(data) {
|
|
40
|
+
return (
|
|
41
|
+
data !== null &&
|
|
42
|
+
typeof data === "object" &&
|
|
43
|
+
Number.isSafeInteger(data.turn) &&
|
|
44
|
+
typeof data.summary === "string" &&
|
|
45
|
+
data.summary.trim() !== "" &&
|
|
46
|
+
typeof data.question === "string" &&
|
|
47
|
+
data.question.trim() !== "" &&
|
|
48
|
+
Array.isArray(data.options) &&
|
|
49
|
+
// 1–2 条:只给 1 条表示「下一步很明确」,不是残缺;3 条以上徒增选择成本。
|
|
50
|
+
data.options.length >= 1 &&
|
|
51
|
+
data.options.length <= 2 &&
|
|
52
|
+
data.options.every(isOption) &&
|
|
53
|
+
(data.options.length === 1 || data.options[0].stance !== data.options[1].stance) &&
|
|
54
|
+
(data.nextPrompt === undefined || typeof data.nextPrompt === "string") &&
|
|
55
|
+
// 新字段出现时必须合法;不出现是旧记录
|
|
56
|
+
(data.value === undefined || isCardValue(data.value)) &&
|
|
57
|
+
(data.shown === undefined || typeof data.shown === "boolean") &&
|
|
58
|
+
(data.tier === undefined || isCardTier(data.tier))
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 写入前的严格校验:新卡必须带齐 v2 字段(服务端写卡时用,避免把半张卡写进会话)。
|
|
64
|
+
* @param {any} data
|
|
65
|
+
* @returns {boolean}
|
|
66
|
+
*/
|
|
67
|
+
export function isCardDataV2(data) {
|
|
68
|
+
return (
|
|
69
|
+
isCardData(data) &&
|
|
70
|
+
isCardValue(data.value) &&
|
|
71
|
+
typeof data.shown === "boolean" &&
|
|
72
|
+
isCardTier(data.tier) &&
|
|
73
|
+
Number.isSafeInteger(data.promptVersion)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 把任意(可能来自旧版本)卡片记录归一化成统一形状。
|
|
79
|
+
* 旧记录缺 `value` → `"must"`(v0.2/v0.3 的卡都是"模型判定需要"才写的);缺 `shown` → `true`。
|
|
80
|
+
* @param {any} data
|
|
81
|
+
* @returns {{
|
|
82
|
+
* turn: number, seq: number, summary: string, question: string,
|
|
83
|
+
* options: { stance: string, label: string }[], nextPrompt?: string,
|
|
84
|
+
* value: "must" | "could" | "no", shown: boolean,
|
|
85
|
+
* tier: "must" | "could" | "any", promptVersion: number,
|
|
86
|
+
* model: string, createdAt: number,
|
|
87
|
+
* }}
|
|
88
|
+
*/
|
|
89
|
+
export function readCard(data) {
|
|
90
|
+
return {
|
|
91
|
+
turn: data.turn,
|
|
92
|
+
seq: Number.isSafeInteger(data.seq) ? data.seq : 0,
|
|
93
|
+
summary: data.summary,
|
|
94
|
+
question: data.question,
|
|
95
|
+
options: data.options.map((/** @type {any} */ option) => ({
|
|
96
|
+
stance: option.stance,
|
|
97
|
+
label: option.label,
|
|
98
|
+
})),
|
|
99
|
+
...(typeof data.nextPrompt === "string" ? { nextPrompt: data.nextPrompt } : {}),
|
|
100
|
+
value: isCardValue(data.value) ? data.value : "must",
|
|
101
|
+
shown: typeof data.shown === "boolean" ? data.shown : true,
|
|
102
|
+
tier: isCardTier(data.tier) ? data.tier : "could",
|
|
103
|
+
promptVersion: Number.isSafeInteger(data.promptVersion) ? data.promptVersion : 0,
|
|
104
|
+
model: typeof data.model === "string" ? data.model : "",
|
|
105
|
+
createdAt: Number.isFinite(data.createdAt) ? data.createdAt : 0,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 揭示记录是否合法。
|
|
111
|
+
* @param {any} data
|
|
112
|
+
* @returns {boolean}
|
|
113
|
+
*/
|
|
114
|
+
export function isRevealData(data) {
|
|
115
|
+
return (
|
|
116
|
+
data !== null &&
|
|
117
|
+
typeof data === "object" &&
|
|
118
|
+
Number.isSafeInteger(data.turn) &&
|
|
119
|
+
(data.via === undefined || data.via === "button" || data.via === "command")
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 决策记录是否合法。
|
|
125
|
+
* @param {any} data
|
|
126
|
+
* @returns {boolean}
|
|
127
|
+
*/
|
|
128
|
+
export function isDecisionData(data) {
|
|
129
|
+
return (
|
|
130
|
+
data !== null &&
|
|
131
|
+
typeof data === "object" &&
|
|
132
|
+
Number.isSafeInteger(data.turn) &&
|
|
133
|
+
(data.phase === "sent" || data.phase === "dismissed") &&
|
|
134
|
+
(data.phase !== "sent" || Number.isSafeInteger(data.index))
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 卡的可见/可交互状态。**host 侧三个守卫(act / dismiss / generateNow)与客户端渲染共用同一套判据**,
|
|
140
|
+
* 所以抽成纯函数并用真值表单测(客户端是 classic script,逻辑镜像一份,测试用同一张表)。
|
|
141
|
+
*
|
|
142
|
+
* - `hidden`:候选被档位抑制、用户还没要求显示 → 不渲染卡片,只渲染补卡按钮
|
|
143
|
+
* - `resolved`:点过或关过 → 只读
|
|
144
|
+
* - `readonly-shown`:显示过但已不是最新回合 → 只读
|
|
145
|
+
* - `interactive-eligible`:最新回合 + 已显示(或已揭示)→ 胶囊可点
|
|
146
|
+
* @param {{ card: any, revealed?: boolean, decision?: any, isLastTurn?: boolean }} input
|
|
147
|
+
* @returns {"hidden" | "resolved" | "readonly-shown" | "interactive-eligible"}
|
|
148
|
+
*/
|
|
149
|
+
export function resolveVisibility(input) {
|
|
150
|
+
if (input.decision !== undefined && input.decision !== null) return "resolved";
|
|
151
|
+
const card = input.card;
|
|
152
|
+
if (card === undefined || card === null) return "hidden";
|
|
153
|
+
const visible = card.shown === true || input.revealed === true;
|
|
154
|
+
if (!visible) return "hidden";
|
|
155
|
+
if (input.isLastTurn === false) return "readonly-shown";
|
|
156
|
+
return "interactive-eligible";
|
|
157
|
+
}
|