@yx333221c/dsh-question-pacing 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +132 -2
- package/README.zh.md +93 -0
- package/client.js +845 -0
- package/cordis.patch.yml +3 -0
- package/core.js +311 -0
- package/docs/DETAIL.md +183 -0
- package/icon.svg +9 -0
- package/index.js +509 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +36 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 yx333221c
|
|
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,133 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Question pacing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English · [简体中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
`ask_user_question` blocks until a human answers. When nobody is looking, the
|
|
6
|
+
turn waits forever — and a model that has been stuck there learns to stop asking
|
|
7
|
+
and start guessing. Question pacing fixes both halves of that: the question card
|
|
8
|
+
gets a countdown so the call always comes back, and the prompt says so, so the
|
|
9
|
+
agent trusts the tool again. A five-level control in the composer decides how
|
|
10
|
+
freely it should reach for it.
|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
- **The question is bounded.** The card counts down; when it ends the tool
|
|
15
|
+
returns `{"pending": true, "callId": …}` and the agent keeps working. The
|
|
16
|
+
question does **not** disappear: it stays answerable in the session, and a
|
|
17
|
+
later answer arrives as its own message. The card's own pause and
|
|
18
|
+
"Take time" button still work — the countdown is the shipped one.
|
|
19
|
+
- **The prompt promises it.** A per-session instruction tells the agent that a
|
|
20
|
+
pending result is not permission, that the question stays open, and how the
|
|
21
|
+
current level wants it to behave. That promise is why the tool becomes safe
|
|
22
|
+
to use again.
|
|
23
|
+
- **Five asking levels**, from `Never ask` to `Always ask`, on a control in the
|
|
24
|
+
composer tool row beside the model selector.
|
|
25
|
+
- **Global defaults plus per-session overrides**, resolved per knob: a session
|
|
26
|
+
that only changes its level keeps following the global countdown.
|
|
27
|
+
|
|
28
|
+
## Using it
|
|
29
|
+
|
|
30
|
+
**Composer → 提问 · 适中** (beside the model selector) opens the level list and
|
|
31
|
+
the countdown list, plus *Follow the defaults* once this session has an override.
|
|
32
|
+
The trigger shows the current level and countdown; a warning dot means this
|
|
33
|
+
session overrides something, and the trigger turns error-coloured with the
|
|
34
|
+
reason in its tooltip if the Host cannot be reached.
|
|
35
|
+
|
|
36
|
+
**Settings → Question pacing** sets the global defaults new sessions inherit.
|
|
37
|
+
|
|
38
|
+
A question that nobody answers keeps a row above the composer — **1 组未回复的问题**
|
|
39
|
+
/ *1 unanswered question* — listing every question still open in this session.
|
|
40
|
+
Choose one to reopen its card and answer. (The composer seat shows only one
|
|
41
|
+
question card at a time, which is why this row exists.)
|
|
42
|
+
|
|
43
|
+
| Level | The agent asks… |
|
|
44
|
+
|---|---|
|
|
45
|
+
| Only when asked | When you explicitly ask to be consulted, or before something irreversible |
|
|
46
|
+
| Ask rarely | Only when a missing fact blocks the work and no tool can find it |
|
|
47
|
+
| Ask sometimes | When the answer changes what gets built and the workspace cannot settle it |
|
|
48
|
+
| Ask often | Before large or hard-to-undo work, and on ambiguous requests |
|
|
49
|
+
| Ask at every step | Before each step that changes the result, unless you said not to ask |
|
|
50
|
+
|
|
51
|
+
A model can still override the countdown for one call, including `timeout: -1`
|
|
52
|
+
to request a genuinely blocking wait.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
Requires DSH `0.2.2-rc.5` or newer (the `engines.dsh` lower bound).
|
|
57
|
+
|
|
58
|
+
The desktop app is the host on this machine and has **no `dsh` CLI on `PATH`**,
|
|
59
|
+
so the app route below is the one that works there.
|
|
60
|
+
|
|
61
|
+
### Through the app (desktop, current profile)
|
|
62
|
+
|
|
63
|
+
1. **Settings → Plugins → Add plugin**, and point it at this plugin's directory
|
|
64
|
+
(a local checkout works; there is no build step).
|
|
65
|
+
2. Enable **Question pacing** in the same list.
|
|
66
|
+
3. Reload the page. The composer control appears next to the model selector and
|
|
67
|
+
the settings section appears under Settings.
|
|
68
|
+
|
|
69
|
+
The equivalent by hand: add
|
|
70
|
+
`"@yx333221c/dsh-question-pacing": "link:<path-to-checkout>"` to
|
|
71
|
+
`%USERPROFILE%\.dsh\profiles\<profile>\package.json`, append the package name to
|
|
72
|
+
`dsh.profile.bundles`, run `pnpm install --dir <profile>`, and restart DSH.
|
|
73
|
+
|
|
74
|
+
### From npm
|
|
75
|
+
|
|
76
|
+
```powershell
|
|
77
|
+
dsh plugin --profile <profile> add @yx333221c/dsh-question-pacing
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### From GitHub
|
|
81
|
+
|
|
82
|
+
This package is plain ESM with no build step, so a git install works as-is:
|
|
83
|
+
|
|
84
|
+
```powershell
|
|
85
|
+
dsh plugin --profile <profile> add github:yx333221c/dsh-question-pacing
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Verify it loaded
|
|
89
|
+
|
|
90
|
+
Ask the agent anything that makes it ask you a question. The card shows a
|
|
91
|
+
countdown in its header; leave it alone and the agent resumes on its own
|
|
92
|
+
instead of waiting forever, and the question reappears as a row above the
|
|
93
|
+
composer. If the composer control turns error-coloured with
|
|
94
|
+
`The Host half is not loaded yet`, the Host row did not activate — check
|
|
95
|
+
**Settings → Plugins**.
|
|
96
|
+
|
|
97
|
+
### Uninstall
|
|
98
|
+
|
|
99
|
+
```powershell
|
|
100
|
+
dsh plugin --profile <profile> remove @yx333221c/dsh-question-pacing
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Removing it restores the shipped blocking tool on the next session; nothing in
|
|
104
|
+
the profile's `cordis.patch.yml` is rewritten by this plugin, and the saved
|
|
105
|
+
settings file can simply be deleted.
|
|
106
|
+
|
|
107
|
+
## Limits
|
|
108
|
+
|
|
109
|
+
- **The countdown applies to the next question.** The native card owns its
|
|
110
|
+
timer, driven by a Host-computed deadline, so a running countdown cannot be
|
|
111
|
+
re-timed from the browser. "Adjustable" means the duration is configurable,
|
|
112
|
+
not that it can be nudged mid-question.
|
|
113
|
+
- **Subagents still cannot ask.** The user-questions service rejects a
|
|
114
|
+
subagent-origin caller; `pending` does not change that boundary.
|
|
115
|
+
- **The Host half installs on live Agents only.** Agents created after the
|
|
116
|
+
plugin loads are covered; a session that was already mid-turn when the plugin
|
|
117
|
+
was enabled picks the new definition up at its next step.
|
|
118
|
+
- **PTC mode is untested.** The projection handles nested `ask_user_question`
|
|
119
|
+
calls, but this plugin was exercised against the native tool executor only.
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
```powershell
|
|
124
|
+
node --check index.js
|
|
125
|
+
node --check client.js
|
|
126
|
+
node --check core.js
|
|
127
|
+
node --test
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`core.js` holds every pure function — level and duration resolution, the layered
|
|
131
|
+
state, the prompt text — covered by `test/core.test.mjs`. `docs/DETAIL.md`
|
|
132
|
+
explains why the tool is shadowed per Agent scope instead of patching a preset,
|
|
133
|
+
and why the schema must keep the `timeout` parameter.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# 提问节奏
|
|
2
|
+
|
|
3
|
+
[English](README.md) · 简体中文
|
|
4
|
+
|
|
5
|
+
`ask_user_question` 会一直等到有人回答。没人看着的时候,这一轮就永远停在原地;而一个被这样卡过的模型,会学会不再提问、改为自己猜。提问节奏把这个问题的两半一起解决:提问卡片带倒计时,工具调用一定会返回;提示词把这件事讲明白,于是 agent 重新敢用这个工具;输入框里的 5 档选择器决定它该多主动地问。
|
|
6
|
+
|
|
7
|
+
## 它做什么
|
|
8
|
+
|
|
9
|
+
- **提问有边界。** 卡片会倒计时,到点后工具返回 `{"pending": true, "callId": …}`,agent 继续干活。问题**不会消失**:它仍然可回答,稍后的回答会作为一条独立消息送达。卡片自带的暂停和「Take time」按钮照常可用——倒计时仍是原生那一套。
|
|
10
|
+
- **提示词把这件事讲清楚。** 每个会话注入一段说明:pending 不等于许可、问题仍然开着、当前档位要求它怎么问。正是这个承诺让工具重新变得安全可用。
|
|
11
|
+
- **5 档提问等级**,从 `不要提问` 到 `必须提问`,位置在输入框工具行、模型选择器旁边。
|
|
12
|
+
- **全局默认 + 每会话覆盖**,按开关分别取值:只在会话里改了等级的,倒计时仍跟随全局。
|
|
13
|
+
|
|
14
|
+
## 怎么用
|
|
15
|
+
|
|
16
|
+
**输入框 → 「提问 · 适中」**(模型选择器旁)展开等级列表和倒计时列表;本会话一旦有覆盖,还会多出「跟随默认设置」。按钮上显示当前等级与倒计时;出现警告点时表示本会话有单独设置,宿主连不通时按钮会变成错误色并把原因写进悬停提示。
|
|
17
|
+
|
|
18
|
+
**设置 → 提问节奏** 设定新会话继承的全局默认值。
|
|
19
|
+
|
|
20
|
+
没人回答的问题会在输入框上方留一行——**「1 组未回复的问题」**——列出本会话里所有仍然开放的问题。点其中一条即可重新打开卡片作答。(输入框一次只显示一张提问卡片,所以需要这一行。)
|
|
21
|
+
|
|
22
|
+
| 档位 | agent 什么时候问 |
|
|
23
|
+
|---|---|
|
|
24
|
+
| 只在被要求时问 | 仅在你明确要求被征询时,或动手前会造成不可逆后果时 |
|
|
25
|
+
| 尽量少问 | 只有缺少某个事实、且工具查不到时才问 |
|
|
26
|
+
| 适中 | 答案会改变产出、且工作区里找不到依据时才问 |
|
|
27
|
+
| 多问 | 大改动、难回退的工作前,以及需求有歧义时 |
|
|
28
|
+
| 每一步都问 | 每个会改变结果的步骤前都问,除非你说过不要问 |
|
|
29
|
+
|
|
30
|
+
模型仍可对单次调用指定倒计时,包括用 `timeout: -1` 明确要求一次真正阻塞的等待。
|
|
31
|
+
|
|
32
|
+
## 安装
|
|
33
|
+
|
|
34
|
+
需要 DSH `0.2.2-rc.5` 或更新版本(即 `engines.dsh` 下限)。
|
|
35
|
+
|
|
36
|
+
本机以桌面应用为宿主,**`PATH` 上没有 `dsh` CLI**,所以请用下面的应用内方式。
|
|
37
|
+
|
|
38
|
+
### 通过应用安装(桌面版,当前 profile)
|
|
39
|
+
|
|
40
|
+
1. **设置 → 插件 → 添加插件**,指向本插件的目录(本地目录即可,没有构建步骤)。
|
|
41
|
+
2. 在同一列表里启用 **提问节奏**。
|
|
42
|
+
3. 刷新页面。输入框工具行出现在模型选择器旁,设置页出现对应分区。
|
|
43
|
+
|
|
44
|
+
手工等价做法:在 `%USERPROFILE%\.dsh\profiles\<profile>\package.json` 的依赖里加
|
|
45
|
+
`"@yx333221c/dsh-question-pacing": "link:<插件目录>"`,把包名追加到
|
|
46
|
+
`dsh.profile.bundles`,执行 `pnpm install --dir <profile>`,然后重启 DSH。
|
|
47
|
+
|
|
48
|
+
### 从 npm 安装
|
|
49
|
+
|
|
50
|
+
```powershell
|
|
51
|
+
dsh plugin --profile <profile> add @yx333221c/dsh-question-pacing
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 从 GitHub 安装
|
|
55
|
+
|
|
56
|
+
本包是纯 ESM、没有构建步骤,git 安装可直接使用:
|
|
57
|
+
|
|
58
|
+
```powershell
|
|
59
|
+
dsh plugin --profile <profile> add github:yx333221c/dsh-question-pacing
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 确认已生效
|
|
63
|
+
|
|
64
|
+
让 agent 提一个问题。卡片头部会显示倒计时;不管它,agent 会自己继续,而不是一直等下去,问题会以上方一行的形式保留下来。如果输入框控件变成错误色并显示「宿主半边尚未加载」,说明宿主那一行没有激活——请到**设置 → 插件**查看。
|
|
65
|
+
|
|
66
|
+
### 卸载
|
|
67
|
+
|
|
68
|
+
```powershell
|
|
69
|
+
dsh plugin --profile <profile> remove @yx333221c/dsh-question-pacing
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
卸载后下一个会话就恢复成原生的阻塞式工具;本插件从不改写 profile 的
|
|
73
|
+
`cordis.patch.yml`,保存的设置文件也可以直接删除。
|
|
74
|
+
|
|
75
|
+
## 限制
|
|
76
|
+
|
|
77
|
+
- **倒计时作用于下一次提问。** 原生卡片自己持有计时器,由宿主计算截止时刻,所以运行中的倒计时无法从浏览器重新定时。「可调」指的是时长可配置,不是能在提问进行中加减。
|
|
78
|
+
- **子 agent 仍然不能提问。** user-questions 服务会拒绝来源为 subagent 的调用方,`pending` 不改变这个边界。
|
|
79
|
+
- **宿主半边只安装在活着的 Agent 上。** 插件加载后创建的 Agent 都会被覆盖;插件启用时正处于一轮对话中的会话,会在下一个 step 用到新定义。
|
|
80
|
+
- **PTC 模式未验证。** 投影逻辑本身支持嵌套的 `ask_user_question` 调用,但本插件只在原生工具执行器下验证过。
|
|
81
|
+
|
|
82
|
+
## 开发
|
|
83
|
+
|
|
84
|
+
```powershell
|
|
85
|
+
node --check index.js
|
|
86
|
+
node --check client.js
|
|
87
|
+
node --check core.js
|
|
88
|
+
node --test
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`core.js` 存放全部纯函数——档位与时长解析、分层状态、提示词文本——由
|
|
92
|
+
`test/core.test.mjs` 覆盖。`docs/DETAIL.md` 说明了为什么用「按 Agent 作用域
|
|
93
|
+
遮蔽工具」而不是改预设,以及为什么 schema 必须保留 `timeout` 参数。
|