@suifei/dsh-ai-team 0.4.30 → 0.4.31
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 +9 -0
- package/index.js +9 -2
- package/lib/host/decision-report.js +14 -4
- package/lib/host/pmo.js +29 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.31 - 2026-11-12
|
|
4
|
+
|
|
5
|
+
**中危批次 2:Host 会话落账、报告路径判别、PMO 决策遵从建议**
|
|
6
|
+
|
|
7
|
+
- **Host 会话现在真的会落账**:`bindHostSession` 一直存在却只在「首次创建」时被调用——从 `roots()` 选中既有根会话、或父级换成另一条根会话时都不会写,`state.hostSessionId` 永远为空,归档修复 sweep 看不见它,父级变化后 `sendMessage`/冷恢复直接 `UNAUTHORIZED` 且无自愈。现在每次解析出 Host 都按现状重绑(幂等),失败留诊断。
|
|
8
|
+
- **报告路径按存在性判别**:一份 Thread 里常先给示例、后给真实路径,文末还可能附模板。现在优先取**真实存在**的那条,都不存在时才退回「最后一次提到」,不再被文末模板或旧稿带走。
|
|
9
|
+
- **PMO 决策遵从问题里的建议**:显式 `recommendation` 现在先按选项字母(`建议 A` ↔ `A. …`)匹配,其次双向包含;只有匹配不上才退回关键词打分。此前关键词打分可以让「建议 A」被选成 B。
|
|
10
|
+
- 测试:`node --test` **211/211**。
|
|
11
|
+
|
|
3
12
|
## 0.4.30 - 2026-11-12
|
|
4
13
|
|
|
5
14
|
**中危批次:唤醒路径收敛与权限预设可配置**
|
package/index.js
CHANGED
|
@@ -1400,9 +1400,16 @@ export function apply(ctx, config = {}) {
|
|
|
1400
1400
|
cwd: booted?.dataDir ?? process.cwd(),
|
|
1401
1401
|
resumeSessionId: existingHost,
|
|
1402
1402
|
}).then(async (value) => {
|
|
1403
|
-
|
|
1404
|
-
|
|
1403
|
+
// Host 会话必须落账:它决定冷恢复与 sendMessage 的 parent,也决定归档
|
|
1404
|
+
// 修复 sweep 能不能看见根会话。除了「首次创建」,从 roots() 里选中
|
|
1405
|
+
// 既有会话、以及父级发生变化(换成了另一条根会话)时同样要重绑——
|
|
1406
|
+
// 否则之后每次 sendMessage/coldResume 都以 UNAUTHORIZED 失败且无自愈。
|
|
1407
|
+
for (const runtime of booted?.runtimes?.values() ?? []) {
|
|
1408
|
+
if (runtime.service.state.hostSessionId === value.sessionId) continue;
|
|
1409
|
+
try {
|
|
1405
1410
|
await runtime.service.bindHostSession(value.sessionId, runtime.id);
|
|
1411
|
+
} catch (error) {
|
|
1412
|
+
diag.append({ ev: 'host.bind.fail', projectId: runtime.id, sessionId: value.sessionId, message: error?.message ?? String(error) });
|
|
1406
1413
|
}
|
|
1407
1414
|
}
|
|
1408
1415
|
host = value;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Read the Human-decision table from a linked Markdown report.
|
|
3
5
|
*
|
|
4
6
|
* This is deliberately narrow: only a report containing a section titled
|
|
@@ -26,13 +28,21 @@ export function findReportPath(text) {
|
|
|
26
28
|
/`[A-Za-z]:[\\/][^`<>|\r\n]+?\.md`/g,
|
|
27
29
|
/[A-Za-z]:[\\/][^\s"'<>|`]+?\.md\b/g,
|
|
28
30
|
];
|
|
29
|
-
|
|
31
|
+
// 命中多个时先看**哪个真的存在**:模型常先给示例路径、再给真实产物路径,文末
|
|
32
|
+
// 也可能附一段模板示例——单靠「取第一个/取最后一个」都会错一边。存在的路径
|
|
33
|
+
// 优先;都不存在时退回「最后一次提到」,那是模型的最终答复约定。
|
|
34
|
+
const hits = [];
|
|
30
35
|
for (const pattern of patterns) {
|
|
31
36
|
for (const match of text.matchAll(pattern)) {
|
|
32
|
-
|
|
37
|
+
hits.push({ index: match.index ?? 0, path: match[0].replace(/^["'`]|["'`]$/g, '') });
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
if (hits.length === 0) return null;
|
|
41
|
+
hits.sort((a, b) => a.index - b.index);
|
|
42
|
+
const existing = hits.filter((hit) => {
|
|
43
|
+
try { return existsSync(hit.path); } catch { return false; }
|
|
44
|
+
});
|
|
45
|
+
return (existing.length > 0 ? existing[existing.length - 1] : hits[hits.length - 1]).path;
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
export function parseDecisionQuestions(markdown) {
|
package/lib/host/pmo.js
CHANGED
|
@@ -14,6 +14,30 @@ function clean(value) {
|
|
|
14
14
|
return typeof value === 'string' ? value.trim() : '';
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/** 选项开头的字母编号(`B.` / `B、` / `B)` / `B:`)。 */
|
|
18
|
+
function optionLetter(value) {
|
|
19
|
+
const match = /^\s*[((]?([A-Za-z])[))..、::]/.exec(value);
|
|
20
|
+
return match === null ? null : match[1].toUpperCase();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 建议里点名的选项字母(`建议 B` / `推荐:C` / `选 A`)。 */
|
|
24
|
+
function recommendationLetter(recommendation) {
|
|
25
|
+
const match = /(?:建议|推荐|选择|选|option|choose)\s*[::]?\s*[((]?([A-Za-z])\b/i.exec(recommendation)
|
|
26
|
+
?? /^\s*[((]?([A-Za-z])[))..、::]/.exec(recommendation);
|
|
27
|
+
return match === null ? null : match[1].toUpperCase();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 显式建议命中哪个选项:字母编号优先,其次双向包含。 */
|
|
31
|
+
function explicitPick(options, recommendation) {
|
|
32
|
+
if (recommendation === '') return null;
|
|
33
|
+
const letter = recommendationLetter(recommendation);
|
|
34
|
+
if (letter !== null) {
|
|
35
|
+
const byLetter = options.find((option) => optionLetter(option) === letter);
|
|
36
|
+
if (byLetter !== undefined) return byLetter;
|
|
37
|
+
}
|
|
38
|
+
return options.find((option) => recommendation.includes(option) || option.includes(recommendation)) ?? null;
|
|
39
|
+
}
|
|
40
|
+
|
|
17
41
|
function scoreOption(option, question) {
|
|
18
42
|
const value = clean(option);
|
|
19
43
|
if (value === '') return -100;
|
|
@@ -36,6 +60,11 @@ export function chooseDecisionAnswers(questions) {
|
|
|
36
60
|
const options = Array.isArray(question?.options) ? question.options.map(clean).filter(Boolean) : [];
|
|
37
61
|
const recommendation = clean(question?.recommendation);
|
|
38
62
|
if (options.length > 0) {
|
|
63
|
+
// 问题里给了明确建议就按建议选——只有没有建议、或建议对不上任何选项时,
|
|
64
|
+
// 才退回关键字打分。否则「建议 A」可能被关键词打分选成 B,PMO 自动决策
|
|
65
|
+
// 就与问题给出的建议相反。
|
|
66
|
+
const explicit = explicitPick(options, recommendation);
|
|
67
|
+
if (explicit !== null) return { id, value: explicit };
|
|
39
68
|
const picked = options
|
|
40
69
|
.map((option) => ({ option, score: scoreOption(option, question) }))
|
|
41
70
|
.sort((left, right) => right.score - left.score)[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suifei/dsh-ai-team",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
|
|
6
6
|
"license": "MIT",
|