dsh-plain-talk 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.en.md +5 -2
- package/README.md +5 -2
- package/dsh/index.js +12 -10
- package/dsh/vocab-policy.js +34 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 0.1.18
|
|
2
|
+
|
|
3
|
+
### 真实宿主事件契约
|
|
4
|
+
|
|
5
|
+
- 修复:真实宿主用 `user/message`(`kind=user`)传用户输入,插件只监听 `agent/inbox/spliced`,导致当轮请求文本始终为空、词汇段落从未注入。两个来源现在都收。
|
|
6
|
+
- 修复:「解释一下 A 和 B」只抓到 A。并列项按连接词展开,每个都取。
|
|
7
|
+
- 并列展开补上否定前缀守卫,避免从「不用解释清单中」抠出假术语。
|
|
8
|
+
- 真实 headless 会话验证:开启时注入块与本地渲染逐字节一致;关闭时零注入。
|
|
9
|
+
## 0.1.17
|
|
10
|
+
|
|
11
|
+
### 产物判定的通用规则
|
|
12
|
+
|
|
13
|
+
- 不再靠逐个补扩展名:以 `.<2-6 位小写字母>` 结尾且主干含下划线、连字符或数字的,一律按文件名处理。
|
|
14
|
+
- 补入 jsonl、ndjson、tsv、parquet、ipynb、lockb 等数据文件扩展名。
|
|
15
|
+
- 实测:`predictions.jsonl`、`session.v4.jsonl`、`metrics.json`、`run_benchmark.py`、`src/index.ts` 全部拒绝;`Docker`、`幂等性`、`GPT-4`、`IRF6` 全部通过。
|
|
16
|
+
- 真实词库再次清理 2 条探测期间写入的 `.jsonl` 记录。
|
|
1
17
|
## 0.1.16
|
|
2
18
|
|
|
3
19
|
### 授权边界与任务产物
|
package/README.en.md
CHANGED
|
@@ -94,7 +94,8 @@ Restart DSH after installing.
|
|
|
94
94
|
- Examples, quotations, code snippets and terms merely used in a task are not confirmations.
|
|
95
95
|
- "Explain X" applies to this turn only; it never flips the long-term preference. Say "always explain X from now on" for that.
|
|
96
96
|
- No guessing: "I think", "probably" and inferred seniority are not confirmations.
|
|
97
|
-
-
|
|
97
|
+
- File names, paths, URLs, session ids, UUIDs and date stamps are never vocabulary, even when the same sentence says "I know this": they are task artifacts, not terms you will keep meeting.
|
|
98
|
+
- Category preferences accept project names only. Requests like "plainly explain computer-science concepts" are rejected with a stated reason.
|
|
98
99
|
|
|
99
100
|
**Switch semantics:** when the toggle is off the plugin injects nothing, records no observations and changes no long-term settings — including the current turn's one-off explain requests. Explicit tool calls you issue still work, because they are your own instruction.
|
|
100
101
|
|
|
@@ -109,7 +110,9 @@ Entry points: tool `plain_talk_vocab` and CLI `node dsh/vocab-cli.js status|list
|
|
|
109
110
|
- `pending` is turn-scoped and dropped.
|
|
110
111
|
- Migration is idempotent. The legacy shared file `$DSH_HOME/plain-talk-vocab.json` is no longer copied into a profile automatically; run `node dsh/vocab-cli.js migrate` under the target profile if you want it.
|
|
111
112
|
|
|
112
|
-
**
|
|
113
|
+
**Verified:** authorization boundaries (code blocks, quotations, third-person retellings, cross-turn), artifact rejection, migration and rollback, concurrent writes under a lock, host contract (prompt section ordering, tool output declarations), standalone loading of the packaged artifact, and injection cost bounds.
|
|
114
|
+
|
|
115
|
+
**Not verified:** whether toggling the switch in the real GUI changes injection on the next turn, and the actual effect on model replies once injection applies. Both have only simulated-context and file-level evidence.
|
|
113
116
|
|
|
114
117
|
## Self-check tool
|
|
115
118
|
|
package/README.md
CHANGED
|
@@ -94,7 +94,8 @@ dsh plugin --profile desktop add ./dsh-plain-talk
|
|
|
94
94
|
- 举例、引用、反引号里的示例、任务里顺带提到的词,都不算确认。"帮我改 Kubernetes 配置"不会让 Kubernetes 变成已知。
|
|
95
95
|
- "解释一下 X"只影响本轮,不改长期偏好;要长期解释得说"以后每次都解释 X"。
|
|
96
96
|
- 不认猜测:说"我猜""应该是"不算确认;插件也不会按你的职业或用量替你推断。
|
|
97
|
-
-
|
|
97
|
+
- 文件名、路径、URL、会话号、UUID、日期编号都不算术语,即使同一句里说"我懂"也拒绝:这些是任务产物,不是你会长期遇到的词。
|
|
98
|
+
- 类别偏好目前只支持项目名(project)。"计算机相关的概念默认简单解释"这类说法会被明确拒绝并说明原因,不会静默忽略。
|
|
98
99
|
|
|
99
100
|
**开关语义:** 关闭时三件事都不做——不注入任何段落、不记录观察、不改长期设置;本轮的一次性解释请求也不保存。你仍然可以显式调用工具加词或改设置,因为那是你亲口下的指令。
|
|
100
101
|
|
|
@@ -109,7 +110,9 @@ dsh plugin --profile desktop add ./dsh-plain-talk
|
|
|
109
110
|
- `pending` 只在当轮有效,迁移时丢弃。
|
|
110
111
|
- 迁移幂等,可重复执行。旧版共享文件 `$DSH_HOME/plain-talk-vocab.json` 不再自动复制进 profile;需要时用 `node dsh/vocab-cli.js migrate` 在目标 profile 下显式迁移。
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
**已验证:** 授权边界(代码块、引用块、第三人称转述、跨轮)、产物拒绝、迁移与回滚、并发写入加锁、宿主契约(提示段落排序、工具输出声明)、打包产物独立加载、注入开销上限。
|
|
114
|
+
|
|
115
|
+
**尚未验证:** 真实图形界面里点击开关后注入是否随之变化,以及注入生效后模型回复的实际效果。这两项只有模拟上下文和文件级证据。
|
|
113
116
|
|
|
114
117
|
## 自检工具
|
|
115
118
|
|
package/dsh/index.js
CHANGED
|
@@ -168,23 +168,25 @@ export function apply(ctx, config = {}) {
|
|
|
168
168
|
const data = event?.data ?? {}
|
|
169
169
|
const enabled = sessionEnabled(id)
|
|
170
170
|
switch (event?.type) {
|
|
171
|
-
case 'agent/inbox/spliced':
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
entry.pending = []
|
|
177
|
-
}
|
|
178
|
-
entry.textsTurn = entry.turn
|
|
179
|
-
for (const message of data.inserted ?? []) {
|
|
171
|
+
case 'agent/inbox/spliced':
|
|
172
|
+
case 'user/message': {
|
|
173
|
+
// 两种来源:spliced 带 inserted 数组,user/message 直接是消息体。
|
|
174
|
+
const incoming = Array.isArray(data.inserted) ? data.inserted : [data]
|
|
175
|
+
for (const message of incoming) {
|
|
180
176
|
const kind = message?.source?.kind
|
|
181
177
|
if (kind && kind !== 'user') continue
|
|
182
178
|
if (message?.role && message.role !== 'user') continue
|
|
183
179
|
const text = textOf(message)
|
|
184
180
|
if (!text || NOT_USER_TEXT.test(text)) continue
|
|
181
|
+
// 真实事件顺序是 splice 先于 turn/start:按“文本所属轮次”判断跨轮。
|
|
182
|
+
if (entry.textsTurn !== undefined && entry.textsTurn !== entry.turn) {
|
|
183
|
+
entry.texts = []
|
|
184
|
+
entry.request = ''
|
|
185
|
+
entry.pending = []
|
|
186
|
+
}
|
|
187
|
+
entry.textsTurn = entry.turn
|
|
185
188
|
entry.texts.push(text)
|
|
186
189
|
entry.request = text
|
|
187
|
-
// 待解释层:本轮明确问到的词 + 本轮任务里出现的术语(只收拉丁术语,中文短语不进)。
|
|
188
190
|
entry.pending = [...new Set([...detectExplainRequest(text), ...extractObservedTerms(text)])].filter(isSafeTerm)
|
|
189
191
|
if (enabled) recordTurn(id, entry.turn, text)
|
|
190
192
|
}
|
package/dsh/vocab-policy.js
CHANGED
|
@@ -68,6 +68,12 @@ const ARTIFACT_EXTENSIONS = new Set([
|
|
|
68
68
|
'rb', 'php', 'sh', 'ps1', 'bat', 'cmd', 'sql', 'html', 'css', 'scss', 'vue',
|
|
69
69
|
'svelte', 'lock', 'zip', 'tar', 'gz', 'tgz', 'png', 'jpg', 'jpeg', 'gif', 'svg',
|
|
70
70
|
'pdf', 'xlsx', 'docx', 'csv', 'xml', 'env', 'map', 'wasm', 'exe', 'dll', 'so',
|
|
71
|
+
'jsonl',
|
|
72
|
+
'ndjson',
|
|
73
|
+
'tsv',
|
|
74
|
+
'parquet',
|
|
75
|
+
'ipynb',
|
|
76
|
+
'lockb',
|
|
71
77
|
])
|
|
72
78
|
|
|
73
79
|
function looksLikeArtifact(text) {
|
|
@@ -419,6 +425,28 @@ const STOP_TERMS = new Set([
|
|
|
419
425
|
])
|
|
420
426
|
|
|
421
427
|
// 从一句请求里抽出“用户要求解释的术语”,保持首次出现的写法。
|
|
428
|
+
// 「解释一下 A 和 B」这类并列:取动词后面整段,按连接词切开,每段只取开头的术语。
|
|
429
|
+
function expandExplainList(source) {
|
|
430
|
+
const out = []
|
|
431
|
+
const verb = /(?:解释(?:一下|下)?|说明(?:一下|下)?|讲(?:一下|讲)?|什么是|啥是)/g
|
|
432
|
+
for (const m of source.matchAll(verb)) {
|
|
433
|
+
// 与主检测器一致:动词前紧贴否定词时跳过(「不用解释X」不是解释请求)。
|
|
434
|
+
const prefix = source.slice(Math.max(0, m.index - 3), m.index)
|
|
435
|
+
if (/(?:不|没|别|未|无)[\u4e00-\u9fa5]?$/.test(prefix)) continue
|
|
436
|
+
const from = m.index + m[0].length
|
|
437
|
+
let run = source.slice(from, from + 80)
|
|
438
|
+
const stop = run.search(/[。!?!?;;\n]/)
|
|
439
|
+
if (stop >= 0) run = run.slice(0, stop)
|
|
440
|
+
for (const chunk of run.split(/和|与|跟|及|以及|、|,|,|\/|\band\b/)) {
|
|
441
|
+
const head = /^\s*([A-Za-z][A-Za-z0-9_.\-+]*|[\u4e00-\u9fa5]{2,8})/.exec(chunk)
|
|
442
|
+
if (!head) continue
|
|
443
|
+
const term = cleanTerm(head[1])
|
|
444
|
+
if (term) out.push(term)
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return out
|
|
448
|
+
}
|
|
449
|
+
|
|
422
450
|
export function detectExplainRequest(text) {
|
|
423
451
|
const source = String(text ?? '')
|
|
424
452
|
if (!source.trim()) return []
|
|
@@ -441,6 +469,12 @@ export function detectExplainRequest(text) {
|
|
|
441
469
|
found.push(raw)
|
|
442
470
|
}
|
|
443
471
|
}
|
|
472
|
+
for (const term of expandExplainList(source)) {
|
|
473
|
+
const key = termKey(term)
|
|
474
|
+
if (seen.has(key)) continue
|
|
475
|
+
seen.add(key)
|
|
476
|
+
found.push(term)
|
|
477
|
+
}
|
|
444
478
|
return found
|
|
445
479
|
}
|
|
446
480
|
|
package/package.json
CHANGED