@kangyishuai/dsh-next-step 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kangyishuai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,126 @@
1
- # Temporary Holding Version
1
+ # @kangyishuai/dsh-next-step
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > A next-step decision card for DeepSeek Harness: after every completed answer, a compact card under it shows where the conversation stands, the question you need to settle, and two mutually exclusive proposals. Click one and its full text is sent as your user message. Optionally — off by default — a grey ghost hint in the empty composer offers the next prompt, accepted with `Tab` or `→`.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@kangyishuai/dsh-next-step?color=cb3837&logo=npm)](https://www.npmjs.com/package/@kangyishuai/dsh-next-step) [![DSH](https://img.shields.io/badge/verified%20on%20DSH-0.2.2--rc.1-4b6bfb)](#compatibility) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6
+
7
+ [中文](./README.zh-CN.md)
8
+
9
+ Unofficial plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness). Not affiliated with DeepSeek.
10
+
11
+ > **Status: early.** Verified against the current target DSH version — see the [Compatibility](#compatibility) table. Both faces sit on host seams that are not public API, so a DSH upgrade can silently disable them (read [Side effects & risks](#side-effects--risks) first). Young software: keep your own notes of anything you would hate to lose.
12
+
13
+ ![Decision card under a completed answer](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/next-step/docs/images/decision-card.png)
14
+
15
+ ## What it does
16
+
17
+ - **A card under every completed answer.** When a turn ends normally, the plugin makes one extra model call and appends a decision card 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 **two pills** for two mutually exclusive directions. Each pill has a short label (up to 20 characters); the full instruction behind it is what gets sent.
18
+ - **One click is one user message.** Clicking a pill puts its full 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
+ - **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
+ - **Resolved, not removed.** After you click, the card stays in the transcript but becomes read-only: summary and question remain, the pills disappear (a sent card may add 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
+ - **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
+ - **Two faces, one call.** Card and ghost are produced together by a single model call — turning the ghost on costs no additional requests.
23
+ - **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
+
25
+ ## Cost & model calls
26
+
27
+ - 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
+ - The call times out after 20 s. Failures, rate limits and malformed JSON are silent: no card, no dialog — only a counter in the plugin's diagnostics. Malformed output is dropped without writing a record.
29
+ - No other network access, no telemetry.
30
+
31
+ ## Side effects & risks
32
+
33
+ - **Appends plugin records to the session log.** One card record per generated card, one decision record per click or dismissal. Nothing is edited or deleted; uninstalling stops rendering them, but the records stay in the log.
34
+ - **Spends model quota** on every completed turn while the card face is on — see [Cost & model calls](#cost--model-calls).
35
+ - **A click overwrites the composer draft.** Sending the pill text goes through the composer shell (`setDraft`, then `submit`), which replaces whatever was in the draft. To protect you, both pills are **disabled while the composer holds any draft**, and the hover hint asks you to clear it first.
36
+ - **What is sent is a normal user message.** It enters the model context and is visible in the transcript exactly as if you had typed it.
37
+ - **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.
38
+ - **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.
39
+ - **Silent failure is by design.** “No card appeared” is not an error dialog; look at the diagnostics counters before filing a bug.
40
+ - **No plugin data directory and no workspace files.** Everything lives in the existing session log; nothing is written under `DSH_HOME` besides the session itself.
41
+ - **Subagent sessions never get cards**, and only normally completed turns are eligible.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ dsh plugin --profile desktop add @kangyishuai/dsh-next-step
47
+ ```
48
+
49
+ To run the working tree instead of a published version, pack it first — `link:` installs do not work (the host's `@deepseek-ai/*` resolution only covers packages whose real path is inside the profile):
50
+
51
+ ```bash
52
+ cd packages/next-step
53
+ pnpm pack --pack-destination /tmp
54
+ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-next-step-*.tgz
55
+ ```
56
+
57
+ Re-run `pnpm pack` + `add` after changing the code. The plugin has a host half, so restart the DSH desktop app and refresh the page.
58
+
59
+ ## Usage
60
+
61
+ **The card.** It appears under the last answer once that turn has completed, and it never steals focus. Each pill carries its short label; click it to send the full instruction. If the summary is folded, use the small expand button to read it all. ✕ dismisses the card; earlier cards are read-only for reference.
62
+
63
+ **The ghost hint.** Turn the ghost face on in the plugin settings. With an empty, idle composer you see the latest card's next prompt in grey, aligned with the host placeholder. `Tab` or `→` accepts it — the text lands in the draft and stays undoable. `Esc` clears it for this suggestion, and the first typed character hides it. It only ever edits the draft: it does not send, and it does not bind Enter.
64
+
65
+ **Where the switches are.** The plugin's settings expose the two faces (`card` / `ghost`), the global switch, the pause and the per-session budget. The global switch off stops requests entirely, not just rendering.
66
+
67
+ ## Settings & diagnostics
68
+
69
+ Settings → **General** → “Next-step suggestions” is one row with everything you need to control it:
70
+
71
+ - **Enable the plugin** — the global switch. Off means **no generation request at all**, not a hidden UI.
72
+ - **Decision card under the answer** / **Ghost hint in the composer** — one switch per face.
73
+ - **Cadence** — “Pause for 1 hour” / “Resume”.
74
+ - **Per session, at most N cards** — the budget (`maxCardsPerSession`, clamped to 0–1000).
75
+ - **Diagnostics** — generated / failed / skipped / in-flight counters, 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.
76
+
77
+ The row writes the same `$DSH_HOME/next-step.settings.json` that the host re-reads (1 s cache) before every generation, so a change applies on the next turn — no restart. If the row is missing because a host seam moved, editing the file still works.
78
+
79
+ ## When no card appears
80
+
81
+ | Situation | What happens |
82
+ | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
83
+ | The turn was stopped, errored, or produced no text | No card: only normally completed turns are eligible. |
84
+ | Subagent session | No card, by design. |
85
+ | Global switch off | No request is made at all; existing cards remain in the transcript. |
86
+ | Paused, or the session's card budget (`maxCardsPerSession`) used up | No new card; existing cards stay. |
87
+ | A card or a decision already exists for that turn | One card per turn; no duplicates. |
88
+ | Model call failed, timed out (20 s), was rate-limited, bad JSON | Silent; only a diagnostics counter goes up. |
89
+ | The reply is still streaming | Nothing is rendered for the turn until it ends. |
90
+ | The composer already has a draft | The card is visible but the pills are disabled until the draft is cleared. |
91
+ | Ghost face on, but the composer is not plain (draft, attachment, `@`, `/`, or a non-idle session) | The hint stays hidden. |
92
+
93
+ ## Known limitations
94
+
95
+ - **The card is attached to the composer area**, not to the transcript. It renders in the composer's overlay layer so it is visible without scrolling; the trade-off is that it reads as part of the input box rather than as a block inside the conversation (ADR 0009 §4).
96
+ - **Exactly two proposals.** Every card has two options that must point in different (mutually exclusive) directions.
97
+ - **The `⌘↵` / `Ctrl+↵` keycap on the primary pill is decorative.** v1 does not bind the shortcut; it is a visual hint only.
98
+ - **No cross-device sync.** Cards and decisions live in the local session log of the machine that generated them.
99
+ - **No cards in subagent sessions**, and none for interrupted or empty turns.
100
+ - **The ghost only offers the latest card's next prompt**, and only when the composer is empty and idle.
101
+ - **The card text is model output.** The plugin validates the shape (two options, distinct stances, label length) but does not rewrite the wording.
102
+
103
+ ![After a click: the summary and question stay, the pills disappear](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/next-step/docs/images/after-click.png)
104
+
105
+ ## Compatibility
106
+
107
+ | DSH version | Status |
108
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
109
+ | 0.2.2-rc.1 | Web composition verified end-to-end on 2026-11-10 (`pnpm smoke:next-step`: 50 passing assertions + 1 skipped settings-page check; real host + real model calls); 67 unit tests; runtime probe 60/60. Desktop real-machine regression verified with `pnpm smoke:next-step-desktop` (`--require`: 9 passing + 1 skip; `--deep`: 19 passing + 2 skips, including a real click that sends a user message). Other DSH versions are not verified. |
110
+
111
+ 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.
112
+
113
+ ## Development
114
+
115
+ ```bash
116
+ pnpm test # unit tests (host generation gates, projection, RPC, client helpers)
117
+ pnpm verify # repo-wide gates
118
+ pnpm smoke:next-step # temp DSH home + real GUI end to end (needs dsh, ego-browser, model credentials)
119
+ pnpm smoke:next-step-desktop # desktop (Electron) read-only; --require for release gates; --deep adds send-path e2e
120
+ ```
121
+
122
+ Test layers, assertions and the manual GUI checklist: [docs/testing/next-step.md](../../docs/testing/next-step.md) (Chinese, like the rest of the repository docs). Design notes: [ADR 0009](../../docs/adr/0009-next-step-architecture.md).
123
+
124
+ ## License
125
+
126
+ MIT
@@ -0,0 +1,126 @@
1
+ # @kangyishuai/dsh-next-step
2
+
3
+ > DeepSeek Harness 的「下一步决策卡」:每条完整回答下方给一张小卡片,写清对话现状、需要你拍板的问题,以及两条互斥的下一步建议;点一条即把该条的完整文本作为用户消息发出。可选(默认关)在空输入框里给一条灰色幽灵提示,`Tab` / `→` 接受。
4
+
5
+ [![npm](https://img.shields.io/npm/v/@kangyishuai/dsh-next-step?color=cb3837&logo=npm)](https://www.npmjs.com/package/@kangyishuai/dsh-next-step) [![DSH](https://img.shields.io/badge/verified%20on%20DSH-0.2.2--rc.1-4b6bfb)](#兼容性) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6
+
7
+ [English](./README.md)
8
+
9
+ 非官方插件,与 DeepSeek 无关。面向 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness)。
10
+
11
+ > **状态:早期。** 已针对当前目标 DSH 版本验证——见[兼容性](#兼容性)表格。卡片与幽灵提示都依赖宿主**私有 seam**,DSH 升级可能让它们静默失效(先读[副作用与风险](#副作用与风险))。插件还年轻,别把重要内容只留一份在这里。
12
+
13
+ ![答后决策卡](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/next-step/docs/images/decision-card.png)
14
+
15
+ ## 它做什么
16
+
17
+ - **每条完整回答下方一张卡。** 一轮正常结束后,插件额外调用一次模型,在回答下方追加一张决策卡:一到三句**现状摘要**(超过两行折叠,带「展开 / 收起」小按钮)、一句点名要你拍板的**提问**,以及**两粒互斥方向**的胶囊。胶囊上只放短标签(不超过 20 字),真正发出去的是它背后的完整指令。
18
+ - **点一下就是一条用户消息。** 点胶囊会把完整文本填入输入框,并走和手动回车**同一条提交链**发出——不是伪造会话事件。空闲会话立即发送;如果已有回合在跑,就和你打字一样排进队列。
19
+ - **刷新也不丢。** 卡片和决策以插件记录的形式追加进会话日志,由宿主的 session projection 折叠,这是唯一的数据来源。刷新页面、切换会话、重开应用都还在;客户端不另存状态。
20
+ - **只读保留,不是消失。** 点过之后卡片仍留在对话里,但变成只读:摘要和提问保留,胶囊消失(已发出的卡可能多一行灰字「已发出」)。更早轮次的卡一律只读,所以任何时刻最多一张卡可交互。卡片右上角的 ✕ 可以收掉这张卡,不发送任何东西。
21
+ - **输入框幽灵提示(默认关)。** 同一次模型调用还会产出一条「下一句提示」。打开 ghost 面后,空且空闲的输入框里会以灰色、和宿主 placeholder 同字号同基线的样子显示它。`Tab` / `→` 接受进草稿(`Ctrl+Z` 可撤销),`Esc` 清除本次建议,开始打字就消失;输入框里有草稿、附件、`@` 引用或斜杠命令时隐藏。幽灵提示**不是草稿内容**,所以空框按 Enter 仍然什么都不会发。
22
+ - **两个面,一次调用。** 卡片和幽灵提示由同一次模型调用一起产出,打开 ghost 不会多花请求。
23
+ - **开关是真的能停。** `card`(默认开)与 `ghost`(默认关)是分开的两个开关;全局开关关闭后**不再发起生成请求**,不是只把 UI 藏起来。另有暂停和每会话卡片预算(`maxCardsPerSession`)限制新卡。已经写进日志的卡仍然可读。
24
+
25
+ ## 成本
26
+
27
+ - 每次触发多一次模型调用,用会话所在智能体当前的模型(取不到时回退到默认模型选择),**占用你自己的 provider 额度**。
28
+ - 这次调用 20 秒超时。失败、限流、JSON 不合法都**静默**:不出卡、不弹框,只在插件诊断里加计数。不合法输出直接丢弃,不写记录。
29
+ - 除此之外不联网,不上报。
30
+
31
+ ## 副作用与风险
32
+
33
+ - **往会话日志追加插件记录。** 每张卡一条 card 记录,每次点击或收起一条 decision 记录;不修改、不删除任何已有内容。卸载后不再渲染,但记录仍留在日志里。
34
+ - **消耗模型额度**:只要 card 面开着,每轮完整回答都会多一次调用,见[成本](#成本)。
35
+ - **点胶囊会覆盖输入框草稿。** 发送走的是宿主 composer shell(`setDraft` 后再 `submit`),会替换草稿内容。为避免误覆盖,**草稿非空时两粒胶囊都禁用**,hover 提示会让你先清空输入框。
36
+ - **发出去的就是普通用户消息。** 它进入模型上下文、出现在对话里,和你自己打字完全一样。
37
+ - **依赖宿主私有 seam。** 卡片渲染走 `conversation.chat.turnTail`;状态来自宿主 session projection(客户端用 `useProjection` 读);点击发送走 composer shell 的 `setDraft` / `submit`(提交前等草稿落定);幽灵提示走 `conversation.input.overlay` 和宿主 placeholder 的 DOM。这些都没有类型、没有版本契约:DSH 升级可能让卡片、发送链或幽灵提示**静默失效**。插件会降级而不是弄坏会话,但升级后请跑 `pnpm probe:runtime`、两个冒烟套件,并看诊断。
38
+ - **幽灵提示和宿主 placeholder DOM 绑在一起**,这也是它默认关的原因;宿主改了那块 DOM,它就只是不显示了。
39
+ - **失败静默是设计。**「没出卡」不是错误弹窗;先看诊断计数再判断是不是 bug。
40
+ - **没有插件数据目录,也不碰工作区文件。** 所有东西都在已有的会话日志里,`DSH_HOME` 下不额外写数据。
41
+ - **子代理会话不出卡**,被停止、报错或没有文本的回合同样不出卡。
42
+
43
+ ## 安装
44
+
45
+ ```bash
46
+ dsh plugin --profile desktop add @kangyishuai/dsh-next-step
47
+ ```
48
+
49
+ 如果要用工作区里的代码而不是发布版,先打包再装——`link:` 装法不行(宿主的 `@deepseek-ai/*` 解析只覆盖真实路径位于 profile 内的包):
50
+
51
+ ```bash
52
+ cd packages/next-step
53
+ pnpm pack --pack-destination /tmp
54
+ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-next-step-*.tgz
55
+ ```
56
+
57
+ 改完代码要重新 `pnpm pack` + `add`。插件带宿主半,装完重启 DSH 桌面版并刷新页面。
58
+
59
+ ## 用法
60
+
61
+ **卡片。** 这一轮正常结束后出现在最后一条回答下方,不抢焦点。胶囊上就是短标签,点击发送完整指令;摘要折叠时用小小的展开按钮看全文。✕ 收掉卡片;更早的卡保持只读,供回看。
62
+
63
+ **幽灵提示。** 在插件设置里打开 ghost 面。输入框空且空闲时,最新一张卡的「下一句提示」以灰色出现,和宿主 placeholder 对齐。`Tab` 或 `→` 接受——文本进入草稿,仍可撤销。`Esc` 清除本次建议,输入第一个字符也会让它消失。它只改草稿:不发送,也不抢 Enter。
64
+
65
+ **开关在哪。** 插件设置里有 card / ghost 两个面、全局开关、暂停,以及每会话预算。全局开关关闭后连请求都不发,不只是不显示。
66
+
67
+ ## 设置与诊断
68
+
69
+ 设置 → **通用** → 「下一步建议」是一行完整控制项:
70
+
71
+ - **启用插件** —— 总开关。关掉之后**完全不发请求**,不是把界面藏起来。
72
+ - **回答下方的决策卡** / **输入框里的幽灵提示** —— 每个面一个开关。
73
+ - **生成节奏** —— 「暂停 1 小时」/「恢复生成」。
74
+ - **每会话最多 N 张卡** —— 预算(`maxCardsPerSession`,夹在 0–1000)。
75
+ - **诊断** —— 已生成 / 失败 / 跳过 / 在途计数、最近错误、**运行时版本 + 构建哈希**、刷新按钮。`nextStep/diagnostics` 同样返回 `version` / `buildHash` / `buildFiles` / `packagePath`,所以运行中的构建可以和 `dsh plugin list` 或 npm 上的 tarball 对照,不需要翻启动日志。
76
+
77
+ 这一行写入的就是宿主每次生成前重读(1s 缓存)的 `$DSH_HOME/next-step.settings.json`,所以改完下一轮就生效、不用重启;万一宿主 seam 变了导致这一行不显示,直接改文件同样有效。
78
+
79
+ ## 什么情况下不出卡
80
+
81
+ | 情况 | 表现 |
82
+ | ------------------------------------------------------- | ---------------------------------------- |
83
+ | 回合被停止、报错,或没有文本 | 不出卡:只有正常结束的回合才有资格。 |
84
+ | 子代理会话 | 按设计不出卡。 |
85
+ | 全局开关关闭 | 完全不发请求;已有卡片仍然留在对话里。 |
86
+ | 已暂停,或用完该会话的卡片预算(`maxCardsPerSession`) | 不出新卡;已有卡片保留。 |
87
+ | 该轮已经有 card 或 decision 记录 | 一轮最多一张卡,不重复。 |
88
+ | 模型调用失败、20 秒超时、限流、JSON 不合法 | 静默;只有诊断计数增加。 |
89
+ | 回答还在流式输出 | 该轮结束前槽位不渲染。 |
90
+ | 输入框里已有草稿 | 卡片照常显示,但胶囊禁用,直到清空草稿。 |
91
+ | ghost 开着,但草稿、附件、`@`、`/` 或输入状态不满足条件 | 提示隐藏。 |
92
+
93
+ ## 已知限制
94
+
95
+ - **卡片贴在输入区上方**(composer 的覆盖层),不排在对话流里。好处是永远不用滚动就能看到建议;代价是它视觉上属于输入框,不是对话正文里的一块(取舍见 ADR 0009 §4)。
96
+ - **固定两条建议。** 每张卡都是两条方向互斥的选项。
97
+ - **primary 胶囊上的 `⌘↵` / `Ctrl+↵` 键帽只是视觉提示。** v1 不绑定这个快捷键。
98
+ - **不做跨设备同步。** 卡片和决策只存在生成它的那台机器的本地会话日志里。
99
+ - **子代理会话不出卡**,被中断或没有文本的回合也不出。
100
+ - **幽灵提示只给最新一张卡的下一句**,且只在输入框为空、会话空闲时出现。
101
+ - **卡片文字来自模型。** 插件会校验形状(两条选项、方向互斥、标签长度),但不改写措辞。
102
+
103
+ ![点过之后:摘要与提问保留、胶囊消失](https://raw.githubusercontent.com/kangyishuai/dsh-plugins/main/packages/next-step/docs/images/after-click.png)
104
+
105
+ ## 兼容性
106
+
107
+ | DSH 版本 | 状态 |
108
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
109
+ | 0.2.2-rc.1 | 2026-11-10 用 web 组合端到端验证通过(`pnpm smoke:next-step`:50 项断言通过 + 1 项设置页断言 SKIP;真实宿主 + 真实模型调用)、单测 67 项、宿主探针 60/60;桌面真机回归已用 `pnpm smoke:next-step-desktop` 验证(`--require`:9 通过 + 1 跳过;`--deep`:19 通过 + 2 跳过,含一次真实点击并发出用户消息)。其他 DSH 版本未验证。 |
110
+
111
+ 插件不声明 `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`,并看插件诊断。
112
+
113
+ ## 开发
114
+
115
+ ```bash
116
+ pnpm test # 单测(宿主生成门、投影、RPC、客户端 helper)
117
+ pnpm verify # 仓库统一门禁
118
+ pnpm smoke:next-step # 临时 DSH 目录 + 真实 GUI 端到端(需要 dsh、ego-browser 与模型凭据)
119
+ pnpm smoke:next-step-desktop # 桌面(Electron)只读回归;发版加 --require;--deep 再跑发送链 e2e
120
+ ```
121
+
122
+ 测试分层、断言清单与手工 GUI 步骤:[docs/testing/next-step.md](../../docs/testing/next-step.md)。设计记录:[ADR 0009](../../docs/adr/0009-next-step-architecture.md)。
123
+
124
+ ## License
125
+
126
+ MIT
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: next-step
3
+ name: "@kangyishuai/dsh-next-step"
@@ -0,0 +1,117 @@
1
+ // @ts-check
2
+ // 运行时自证的构建身份:版本号 + 构建哈希。
3
+ //
4
+ // 为什么需要它:插件装没装、装的是哪个版本,过去只能靠 `dsh plugin list`、profile 的 lock 文件、
5
+ // 或者启动日志去侧面推断。这里让插件自己报出来——`diagnostics` RPC 会带上 `version` 与
6
+ // `buildHash`,和 `dsh plugin list` / npm 上的 tarball 一比就能确认「现在跑的是不是那份代码」。
7
+ //
8
+ // 只依赖 Node 内置模块,不进宿主包,因此可以用 `node --test` 直接测。
9
+ import { createHash } from "node:crypto";
10
+ import { readdir, readFile } from "node:fs/promises";
11
+ import { join, relative, sep } from "node:path";
12
+ import { fileURLToPath } from "node:url";
13
+
14
+ /** 插件包根目录(本文件在 <root>/lib/ 下)。 */
15
+ export const PACKAGE_ROOT = fileURLToPath(new URL("..", import.meta.url));
16
+
17
+ /**
18
+ * 参与构建哈希的条目(相对包根)。刻意不含 README / LICENSE:
19
+ * 它们不影响行为,改文档不该让用户看到「构建变了」。
20
+ */
21
+ const HASHED_ENTRIES = ["package.json", "cordis.patch.yml", "lib", "locale"];
22
+
23
+ /**
24
+ * 递归收集普通文件(不跟随符号链接)。
25
+ * @param {string} absolute 绝对路径
26
+ * @param {string[]} out 收集结果
27
+ * @returns {Promise<void>}
28
+ */
29
+ async function collect(absolute, out) {
30
+ let entries;
31
+ try {
32
+ entries = await readdir(absolute, { withFileTypes: true });
33
+ } catch (_error) {
34
+ return;
35
+ }
36
+ for (const entry of entries) {
37
+ const child = join(absolute, entry.name);
38
+ if (entry.isDirectory()) await collect(child, out);
39
+ else if (entry.isFile()) out.push(child);
40
+ }
41
+ }
42
+
43
+ /**
44
+ * 归一化相对路径:统一用 `/`,保证 macOS / Linux / Windows 上哈希一致。
45
+ * @param {string} absolute
46
+ * @returns {string}
47
+ */
48
+ function relativeKey(absolute) {
49
+ return relative(PACKAGE_ROOT, absolute).split(sep).join("/");
50
+ }
51
+
52
+ /**
53
+ * 计算一次构建身份:读 package.json 的 version,并对参与构建的文件做 sha256。
54
+ * @returns {Promise<{ version: string, buildHash: string, buildFiles: number, packagePath: string }>}
55
+ */
56
+ export async function computeBuildIdentity() {
57
+ const pkgText = await readFile(join(PACKAGE_ROOT, "package.json"), "utf8");
58
+ /** @type {{ version?: unknown }} */
59
+ const pkg = JSON.parse(pkgText);
60
+ const version = typeof pkg.version === "string" ? pkg.version : "0.0.0";
61
+
62
+ /** @type {string[]} */
63
+ const absoluteFiles = [];
64
+ for (const entry of HASHED_ENTRIES) {
65
+ const absolute = join(PACKAGE_ROOT, entry);
66
+ try {
67
+ const stats = await readdir(absolute, { withFileTypes: true });
68
+ if (Array.isArray(stats)) await collect(absolute, absoluteFiles);
69
+ } catch (_error) {
70
+ // 不是目录:当作单文件处理(package.json / cordis.patch.yml)
71
+ absoluteFiles.push(absolute);
72
+ }
73
+ }
74
+
75
+ /** @type {{ key: string, path: string }[]} */
76
+ const files = absoluteFiles
77
+ .map((path) => ({ key: relativeKey(path), path }))
78
+ .sort((left, right) => (left.key < right.key ? -1 : left.key > right.key ? 1 : 0));
79
+
80
+ const hash = createHash("sha256");
81
+ for (const file of files) {
82
+ const content = await readFile(file.path);
83
+ hash.update(file.key);
84
+ hash.update("\u0000");
85
+ hash.update(String(content.length));
86
+ hash.update("\u0000");
87
+ hash.update(content);
88
+ hash.update("\u0000");
89
+ }
90
+
91
+ return {
92
+ version,
93
+ buildHash: hash.digest("hex"),
94
+ buildFiles: files.length,
95
+ packagePath: PACKAGE_ROOT,
96
+ };
97
+ }
98
+
99
+ /** @type {Promise<{ version: string, buildHash: string, buildFiles: number, packagePath: string }> | null} */
100
+ let cached = null;
101
+
102
+ /**
103
+ * 缓存的构建身份(第一次调用后不再读盘;插件进程内版本不会变)。
104
+ * @returns {Promise<{ version: string, buildHash: string, buildFiles: number, packagePath: string }>}
105
+ */
106
+ export function buildIdentity() {
107
+ if (cached === null) cached = computeBuildIdentity();
108
+ return cached;
109
+ }
110
+
111
+ /**
112
+ * 只清缓存,给测试用(运行时不会调用)。
113
+ * @returns {void}
114
+ */
115
+ export function resetBuildIdentityCache() {
116
+ cached = null;
117
+ }