@suifei/dsh-ai-team 0.4.40 → 0.4.41
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 +10 -0
- package/index.js +31 -5
- package/lib/host/service.js +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.41 - 2026-11-12
|
|
4
|
+
|
|
5
|
+
**批 10:收割幂等、句柄回收、别名原子写、自动作答边界**
|
|
6
|
+
|
|
7
|
+
- **收割可恢复**:`applyLiveAtomically` 与「写 results/终态」之间崩溃,上一版会让下一轮把 live ≠ before 判成 conflict——一次成功的 `keep` 被判失败。现在先判定「live 已等于候选」(`alreadyApplied`)走幂等收尾,并在改 live 前把 `decision/backup/applyingSince` 落进 job 记录。
|
|
8
|
+
- **退役/离队回收冷恢复句柄**:`resumedHandles` 与 `activations` 分开登记,之前只回收后者,冷恢复出来的成员会话会一直挂在进程里。
|
|
9
|
+
- **人员别名原子写**:写临时文件再 rename;且**读取失败不再当空表**覆盖——文件损坏时返回 409 让用户先修正,而不是把已有别名清空。
|
|
10
|
+
- **自动作答只回答有问题的决策**:成员致命失败生成的升级项没有 `questions`,自动作答会用一句通用话术把它 `resolved`,Human 再也看不到真正的失败。
|
|
11
|
+
- 测试:`node --test` **243/243**(新增 1 例)。
|
|
12
|
+
|
|
3
13
|
## 0.4.40 - 2026-11-12
|
|
4
14
|
|
|
5
15
|
**批 9:依赖可达性、账本修复入口、job 状态机、投票解析统一**
|
package/index.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
12
|
import { join } from 'node:path';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
|
-
import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import { existsSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
15
15
|
import z from '@deepseek-ai/schemastery';
|
|
16
16
|
import { ProjectRuntime } from './lib/host/project-runtime.js';
|
|
17
17
|
import { ProjectRegistry } from './lib/host/project-registry.js';
|
|
@@ -1292,20 +1292,30 @@ export function apply(ctx, config = {}) {
|
|
|
1292
1292
|
// 一次 revert 用陈旧快照覆盖(反之亦然)。
|
|
1293
1293
|
let liveText = null;
|
|
1294
1294
|
try { liveText = existsSync(job.skillPath) ? readFileSync(job.skillPath, 'utf8') : null; } catch { liveText = null; }
|
|
1295
|
-
|
|
1295
|
+
// live 与候选一致 = 上一次已经落过盘、只差收尾(进程在「改 live」与
|
|
1296
|
+
// 「写 results/终态」之间崩溃)。这不是 conflict:按 conflict 处理会把
|
|
1297
|
+
// 一次成功的 keep 在下一轮判成失败。
|
|
1298
|
+
const liveSha = liveText === null ? null : sha12(liveText);
|
|
1299
|
+
const candidateSha = typeof job.candidate === 'string' ? sha12(job.candidate) : null;
|
|
1300
|
+
const alreadyApplied = liveSha !== null && candidateSha !== null && liveSha === candidateSha;
|
|
1301
|
+
if (!alreadyApplied && liveText !== null && typeof job.before === 'string' && liveSha !== sha12(job.before)) {
|
|
1296
1302
|
writeJob(jobDir, { ...job, state: 'failed', error: 'live SKILL.md changed during review (conflict)', updatedAt: Date.now() });
|
|
1297
1303
|
await closeReviewCard(runtime, job.reviewTaskId, 'blind review aborted: live file changed');
|
|
1298
1304
|
diag.append({ ev: 'skillopt.job.conflict', jobId: job.id, skillPath: job.skillPath });
|
|
1299
1305
|
continue;
|
|
1300
1306
|
}
|
|
1307
|
+
if (alreadyApplied) diag.append({ ev: 'skillopt.job.resume', jobId: job.id, reason: 'candidate already applied' });
|
|
1301
1308
|
let backupPath = null;
|
|
1302
1309
|
try {
|
|
1303
1310
|
backupPath = backupLive({ projectDir: jobDir, skillPath: job.skillPath, text: liveText ?? job.before ?? '' });
|
|
1304
1311
|
} catch (error) {
|
|
1305
1312
|
diag.append({ ev: 'skillopt.job.backup.fail', jobId: job.id, message: error?.message ?? String(error) });
|
|
1306
1313
|
}
|
|
1314
|
+
// 先把决定落成 job 记录:进程若在「改 live」之后崩溃,下一次仍能看出
|
|
1315
|
+
// 这次要收尾成什么(配合上面的 alreadyApplied 幂等判定)。
|
|
1316
|
+
writeJob(jobDir, { ...job, decision: collected.decision, backup: backupPath ?? job.backup ?? null, applyingSince: Date.now() });
|
|
1307
1317
|
// keep → 落盘候选;revert → 恢复基线(评审卡收票后才动文件)。
|
|
1308
|
-
applyLiveAtomically(job.skillPath, kept ? job.candidate : job.before);
|
|
1318
|
+
if (!alreadyApplied) applyLiveAtomically(job.skillPath, kept ? job.candidate : job.before);
|
|
1309
1319
|
const beforeScore = scoreSkillRubric(job.before, { measured: false })?.total ?? null;
|
|
1310
1320
|
const afterScore = scoreSkillRubric(kept ? job.candidate : job.before, { measured: false })?.total ?? null;
|
|
1311
1321
|
const appender = makeResultAppender({ projectDir: jobDir });
|
|
@@ -1751,13 +1761,21 @@ export function apply(ctx, config = {}) {
|
|
|
1751
1761
|
if (memberName === '' || personId === '') {
|
|
1752
1762
|
return send(res, { error: { code: 'E_INVALID_ARGUMENT', message: 'name and personId are required' } }, 400);
|
|
1753
1763
|
}
|
|
1754
|
-
|
|
1764
|
+
// 读失败/文件损坏不能当成空表:那会把用户已有的别名整文件覆盖掉。
|
|
1765
|
+
const existing = readAliases();
|
|
1766
|
+
if (existing === null && existsSync(aliasesPath)) {
|
|
1767
|
+
return send(res, { error: { code: 'E_UNREADABLE', message: 'people-aliases.json 无法解析;请先修正或删除该文件再绑定' } }, 409);
|
|
1768
|
+
}
|
|
1769
|
+
const aliases = existing ?? {};
|
|
1755
1770
|
// 归一到视图层的桶键:接受 `person:<id>`、`name:<名字>` 或裸名字。
|
|
1756
1771
|
// 归一后才能与 aggregatePeople 的桶键对齐(裸名字曾让两行永不合并,
|
|
1757
1772
|
// 而界面还提示「已绑定」)。
|
|
1758
1773
|
const normalized = personId.startsWith('person:') || personId.startsWith('name:') ? personId : `name:${personId}`;
|
|
1759
1774
|
aliases[memberName] = normalized;
|
|
1760
|
-
|
|
1775
|
+
// 原子写:先写临时文件再改名,半个文件会让下一次读取直接判损坏。
|
|
1776
|
+
const tempPath = `${aliasesPath}.tmp`;
|
|
1777
|
+
writeFileSync(tempPath, JSON.stringify(aliases, null, 2) + '\n', 'utf8');
|
|
1778
|
+
renameSync(tempPath, aliasesPath);
|
|
1761
1779
|
diag?.append({ ev: 'people.alias', name: memberName, personId });
|
|
1762
1780
|
return send(res, { ok: true, aliases });
|
|
1763
1781
|
}
|
|
@@ -2231,6 +2249,14 @@ export function apply(ctx, config = {}) {
|
|
|
2231
2249
|
try { await activation.dispose?.(); } catch { /* already gone */ }
|
|
2232
2250
|
diag.append({ ev: 'member.activation.disposed', memberId: retiredId, sessionId: retiredSession, reason: body.type });
|
|
2233
2251
|
}
|
|
2252
|
+
// 冷恢复得到的 handle 也要回收:它同样常驻进程,且不会因为
|
|
2253
|
+
// activation 被 dispose 而消失(两套句柄分开登记)。
|
|
2254
|
+
const resumed = resumedHandles.get(retiredSession);
|
|
2255
|
+
if (resumed !== undefined) {
|
|
2256
|
+
resumedHandles.delete(retiredSession);
|
|
2257
|
+
try { await resumed.dispose?.(); } catch { /* already gone */ }
|
|
2258
|
+
diag.append({ ev: 'member.resumed-handle.disposed', memberId: retiredId, sessionId: retiredSession, reason: body.type });
|
|
2259
|
+
}
|
|
2234
2260
|
}
|
|
2235
2261
|
}
|
|
2236
2262
|
send(res, { ok: true, ...result });
|
package/lib/host/service.js
CHANGED
|
@@ -1341,10 +1341,14 @@ export class TeamService {
|
|
|
1341
1341
|
// 合同是「返回回答列表」:这里曾返回数字 0,调用方按数组迭代时抛 TypeError,
|
|
1342
1342
|
// 整个 PMO tick 被打断且每个 tick 都重复失败。
|
|
1343
1343
|
if (humanId === null || humanId === undefined) return [];
|
|
1344
|
+
// 只自动回答**有结构化问题**的决策项。成员致命失败生成的升级项没有 questions,
|
|
1345
|
+
// 自动作答会用一句通用话术把它 resolved,Human 再也看不到真正的失败。
|
|
1344
1346
|
const items = Object.values(this.state.inbox ?? {}).filter((item) =>
|
|
1345
1347
|
item.memberId === humanId
|
|
1346
1348
|
&& item.type === 'decision_required'
|
|
1347
|
-
&& item.state === 'unread'
|
|
1349
|
+
&& item.state === 'unread'
|
|
1350
|
+
&& Array.isArray(item.ref?.questions)
|
|
1351
|
+
&& item.ref.questions.length > 0);
|
|
1348
1352
|
const results = [];
|
|
1349
1353
|
for (const item of items) {
|
|
1350
1354
|
const questions = Array.isArray(item.ref?.questions) ? item.ref.questions : [];
|
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.41",
|
|
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",
|