@suifei/dsh-ai-team 0.4.113 → 0.4.116

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 CHANGED
@@ -1,5 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.116 - 2026-11-17
4
+
5
+ **空看板不再永久静默;成员知道后台任务活不过回合;说人话**
6
+
7
+ - il2c 11-17 实账本:03:55 最后一张卡验收,`wave_done` 送达主理人(PMO 记为「已看过局面」)。主理人回「波尾刀本回合即起」,
8
+ 在后台起了 13–23 分钟的全量批后收尾;回合结束 34ms 后会话释放,批被杀(`job/settled` killed / teardown),无人通知。
9
+ 此后无人建卡、Human 无输入,PMO 每轮判「无新进展」,看板空转到 09:00;
10
+ - PMO:静默不再是永久的。没有成员在回合里、静默满 30 分钟就再推进一次,之后间隔翻倍(60、120 … 封顶 8 小时),
11
+ 自主批次预算照旧把关(`planIdleRetry`,`lib/host/pmo.js`;诊断行 `pmo.continue.idle`);
12
+ - 团队纪律新增两条:后台任务活不过回合,长命令本回合前台跑完或拆成 Task;PMO 自动推进开启时看板空了自己开下一批,
13
+ 不等 Human 下令「开下一波」;
14
+ - 「用平实中文写」从一句口号改成具体规则:看板、回帖、汇报、个性、笔记一律写给第一次看的人,不用「刀/席/拍/腿/宣/波尾」
15
+ 这类代号、「料-13」这类自编缩写和「∥」连写。成员资料里这些字累计数百处(墨渊 304、观澜 230、评审官 233),
16
+ 且每回合都会被成员自己读到;`evolve/distill/note` 的参数说明同步写明;
17
+ - 测试:`test/pmo-nudges.test.js`、`test/team-discipline.test.js` 各新增 1 例(去掉修复即失败);
18
+
19
+ ## 0.4.115 - 2026-11-17
20
+
21
+ **受限宿主只记一行 boot.refused,不再连带两行派生 .fail**
22
+
23
+ - 实机诊断日志(errors 级)11-14 / 11-16 各有 44 / 42 次 `skillopt.skip.fail`:每次都紧跟在
24
+ `service.missing.fail`(无 sessions/subagents)+ `boot.refused`(workspace-write)之后,同时还有一行
25
+ `team.discipline.section.unavailable.fail`——插件被加载进不跑团队的受限宿主,后两行是同一原因的派生;
26
+ - 启动被拒时不再记这两行;full-access 宿主缺工具注册或提示词段时照常报错;
27
+ - 测试:`test/diag-sink.test.js` 新增 2 例,用真实 `apply()` 分别在受限 / full-access 宿主下检查落盘的诊断行
28
+ (去掉修复,受限宿主一例即失败);
29
+
30
+ ## 0.4.114 - 2026-11-16
31
+
32
+ **SkillOpt 判分不再因答复开头复述 JSON 格式而全部记零**
33
+
34
+ - il2c night 11(0.4.113,干净采集 1 会话 → 2 任务):所有判分都记成 `judge-parse-failed`,留出集 0.000 → 0.000,
35
+ 而判分子代理实际给出 0.6 / 0.85 / 0.78。答复先写一段说明、复述题面「return only JSON {"score": <0..1>, …}」,
36
+ 末尾才是真 JSON;`_extract_json` 的贪婪 `\{.*\}` 从复述处吃到末尾,解析失败;
37
+ - `_extract_json`:最宽跨度解析失败时,取最后一个能解析的同类 JSON 值(判分、挖任务、反思共用);
38
+ - `judge`:对象解析不出时兜底取最后一个 `"score": 数字`(night 11 有 1/11 份答复漏了收尾 `}`),原因记 `judge-score-only`;
39
+ - 测试:`test/skillopt-dsh-source.test.js` 新增 1 例(去掉修复即失败);
40
+
3
41
  ## 0.4.113 - 2026-11-16
4
42
 
5
43
  **dsh 来源也跳过「替引擎答题」的会话,不论谁派的**
package/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * The member runtime (real Agent sessions) lands in M2. Until then the
9
9
  * ledger/domain service is the only writer and the Host never fakes work.
10
10
  */
11
- import { planDispatch, planTaskNudges } from './lib/host/pmo.js';
11
+ import { planDispatch, planIdleRetry, planTaskNudges } from './lib/host/pmo.js';
12
12
  import { pmoHasNews } from './lib/ledger/fold.js';
13
13
  import { homedir, tmpdir } from 'node:os';
14
14
  import { randomUUID } from 'node:crypto';
@@ -697,7 +697,9 @@ export function apply(ctx, config = {}) {
697
697
  systemPrompt: serviceOf(ctx, 'systemPrompt'),
698
698
  on: typeof ctx.on === 'function' ? (name, listener) => ctx.on(name, listener) : undefined,
699
699
  teamProjectOf,
700
- diag,
700
+ // 受限宿主(boot.refused:无会话/子代理服务、非 full-access)本就不跑团队,
701
+ // 缺 systemPrompt 段是同一原因的派生,不再各记一行 .fail(il2c 11-16:42 次)。
702
+ diag: access.ok ? diag : undefined,
701
703
  newId: randomUUID,
702
704
  });
703
705
  } catch (error) {
@@ -840,7 +842,8 @@ export function apply(ctx, config = {}) {
840
842
  const requestAttempts = new Map();
841
843
  const activationTasks = new Map();
842
844
  const pmoLastKick = new Map();
843
- const pmoQuiet = new Set();
845
+ /** 空看板静默的项目:projectId → { since, lastAt, retries }(planIdleRetry 用)。 */
846
+ const pmoQuiet = new Map();
844
847
  const pmoLastStall = new Map();
845
848
  const pmoLastHeartbeat = new Map();
846
849
  const pmoLastDispatch = new Map();
@@ -1309,13 +1312,20 @@ export function apply(ctx, config = {}) {
1309
1312
  // PMO 已看过当前局面(汇报 / 推进 / 回复 Human)且之后没有新进展:不再推进,
1310
1313
  // 否则目标完成后每 10 分钟空转一次会议(见 fold.js pmoNews)。每段静默只记一次。
1311
1314
  if (!pmoHasNews(state)) {
1312
- if (!pmoQuiet.has(projectRuntime.id)) {
1313
- pmoQuiet.add(projectRuntime.id);
1315
+ const quiet = pmoQuiet.get(projectRuntime.id);
1316
+ if (quiet === undefined) {
1317
+ pmoQuiet.set(projectRuntime.id, { since: now, lastAt: now, retries: 0 });
1314
1318
  diag.append({ ev: 'pmo.continue.quiet', projectId: projectRuntime.id, seq: state.lastSeq });
1319
+ return;
1315
1320
  }
1316
- return;
1321
+ // 静默不是永久的:没人在跑且静默够久,再推进一次(规则见 planIdleRetry)。
1322
+ if (!planIdleRetry(state, { ...quiet, now, inTurn: (id) => turnsInFlight.has(id) })) return;
1323
+ quiet.lastAt = now;
1324
+ quiet.retries += 1;
1325
+ diag.append({ ev: 'pmo.continue.idle', projectId: projectRuntime.id, retries: quiet.retries, quietMs: now - quiet.since });
1326
+ } else {
1327
+ pmoQuiet.delete(projectRuntime.id);
1317
1328
  }
1318
- pmoQuiet.delete(projectRuntime.id);
1319
1329
  const last = pmoLastKick.get(projectRuntime.id) ?? 0;
1320
1330
  if (now - last < 10 * 60_000) return;
1321
1331
  pmoLastKick.set(projectRuntime.id, now);
@@ -1428,7 +1438,7 @@ export function apply(ctx, config = {}) {
1428
1438
  // shell 惰性代理:注入时机早于 shell 服务就绪时,注册仍必须完成——
1429
1439
  // 每次调用现取,避免「boot 时 shell 未就绪 → 整条技能链静默跳过」。
1430
1440
  const shellProxy = lazyShellService(ctx);
1431
- if (!tools?.register) {
1441
+ if (!tools?.register && access.ok) {
1432
1442
  diag.append({ ev: 'skillopt.skip.fail', hasToolsRegister: false, hasShell: Boolean(serviceOf(ctx, 'shell')) });
1433
1443
  console.warn('[ai-team] SkillOpt tools not registered: no tool registry');
1434
1444
  }
@@ -103,10 +103,10 @@ export function createTeamTool(options) {
103
103
  required: ['text'],
104
104
  },
105
105
  },
106
- personality: { type: 'string', description: 'New working personality for evolve/distill.' },
106
+ personality: { type: 'string', description: 'New working personality for evolve/distill. Plain Chinese a newcomer can read: general ways of working, no team code words, coined abbreviations or task-specific numbers.' },
107
107
  reason: { type: 'string', description: 'Why the personality changed.' },
108
108
  memberId: { type: 'string', description: 'Target member for member/distill/note/skill.' },
109
- text: { type: 'string', description: 'Note text.' },
109
+ text: { type: 'string', description: 'Note text, in plain Chinese a newcomer can read: say what happened and what to do next; no team code words or coined abbreviations.' },
110
110
  query: { type: 'string', description: 'Keyword for recall.' },
111
111
  skill: { type: 'string', description: 'Skill name to add.' },
112
112
  },
package/lib/host/pmo.js CHANGED
@@ -140,3 +140,30 @@ export function planDispatch(task, state, { inTurn, last = { at: 0, count: 0 },
140
140
  if (last.count >= PMO_DISPATCH_LIMIT || now - last.at < 60_000) return null;
141
141
  return responsibleId;
142
142
  }
143
+
144
+ /** 空看板静默后的首次重推间隔;之后每次翻倍,封顶 PMO_IDLE_RETRY_MAX。 */
145
+ export const PMO_IDLE_RETRY_BASE = 30 * MINUTE;
146
+ export const PMO_IDLE_RETRY_MAX = 8 * 60 * MINUTE;
147
+
148
+ /**
149
+ * 空看板且「PMO 已看过局面、此后无新进展」(pmoNews=false)时,是否再推进一次。
150
+ *
151
+ * 静默本是为了防目标完成后每 10 分钟空转开会(r09);但永久静默会把团队卡死。il2c 11-17:
152
+ * 03:55 wave_done 送达主理人(pmoNews→false),主理人说「波尾刀本回合即起」、起了后台批就收尾,
153
+ * 后台批随会话释放被杀(job/settled killed/teardown),此后无人建卡、Human 也无输入,
154
+ * PMO 每轮都判「无新进展」,看板空转到天亮。
155
+ *
156
+ * 规则:静默期间没有成员在回合里,且距上次推进(或静默开始)已满 30 分钟 × 2^次数(封顶 8 小时),
157
+ * 就再推进一次;预算闸(pmoGate)照旧把关,用尽即停。
158
+ *
159
+ * @param {any} state 账本投影
160
+ * @param {{ since: number, lastAt?: number, retries?: number, now: number, inTurn: (sessionId: string) => boolean }} options
161
+ * @returns {boolean}
162
+ */
163
+ export function planIdleRetry(state, { since, lastAt = since, retries = 0, now, inTurn }) {
164
+ const busy = Object.values(state?.members ?? {}).some((member) =>
165
+ member?.kind === 'agent' && typeof member.sessionId === 'string' && inTurn(member.sessionId));
166
+ if (busy) return false;
167
+ const wait = Math.min(PMO_IDLE_RETRY_BASE * 2 ** retries, PMO_IDLE_RETRY_MAX);
168
+ return now - lastAt >= wait;
169
+ }
@@ -61,7 +61,9 @@ export const TEAM_DISCIPLINE_TEXT = [
61
61
  '- 等待要有边界:等别人交付或外部进程时,现在就开始盯,说清隔多久查一次、最多盯多久;到时没结果就升级或换路,不空等。',
62
62
  '- 不提前收兵:还有能推进的事,或下一步的前置条件已经满足,就继续做。只有三种情况可以停:目标已达成、自主批次已用尽、需要 Human 拍板;停的时候写明是哪一种。',
63
63
  '- 先核实再宣称:说「正常」「已恢复」「会自动跑」之前,先读状态、退出码、日志时间戳,不凭推断。',
64
- '- 用平实中文写:不自创术语和缩写,Human 和其他成员要能直接看懂。',
64
+ '- 后台任务活不过回合:你的回合一结束,会话就会被释放,你在后台启动的命令随之被杀,也不会有任何通知叫醒你。耗时长的命令就在本回合里前台跑完(给足超时),或拆成 Task 交给别人;不要结束回合去「等批跑完」。',
65
+ '- PMO 自动推进开启时自己推进:看板空了就按目标开下一批 Task,不等 Human 下令「开下一波」;只有目标已达成、预算用尽或确实需要 Human 拍板时才停。',
66
+ '- 用平实中文写,写给第一次看的人:看板、回帖、汇报、个性、笔记都一样。说清做了什么、结果是什么、下一步是什么。不要用团队里约定俗成的代号和比喻(如「刀」「席」「拍」「腿」「宣」「波尾」)、自编的编号缩写(如「料-13」「格④」)和「∥」连写;专有名词第一次出现时用一句话解释。',
65
67
  ].join('\n');
66
68
 
67
69
  /**
@@ -292,15 +292,36 @@ class MockBackend(Backend):
292
292
  # ── Shared real-CLI backend (prompts + parsing + cache; subclasses do _call) ──
293
293
 
294
294
  def _extract_json(raw: str, kind: str):
295
- """Pull the first JSON object/array out of a possibly chatty CLI reply."""
296
- pat = r"\{.*\}" if kind == "object" else r"\[.*\]"
297
- m = re.search(pat, raw or "", re.DOTALL)
298
- if not m:
295
+ """Pull the JSON object/array out of a possibly chatty CLI reply.
296
+
297
+ The widest span (first opener .. last closer) is tried first, as before.
298
+ When it does not parse -- a reply that restates the requested format, e.g.
299
+ 'return only JSON {"score": <0..1>, ...}', before the real answer -- the
300
+ last value of the requested kind that does parse is taken: chatty replies
301
+ put the answer at the end (il2c night 11: every judge reply was scored
302
+ judge-parse-failed although each ended with a valid {"score": ...}).
303
+ """
304
+ text = raw or ""
305
+ opener, closer, want = ("{", "}", dict) if kind == "object" else ("[", "]", list)
306
+ first, last = text.find(opener), text.rfind(closer)
307
+ if first < 0 or last < first:
299
308
  return None
300
309
  try:
301
- return json.loads(m.group(0))
310
+ return json.loads(text[first:last + 1])
302
311
  except Exception:
303
- return None
312
+ pass
313
+ decoder = json.JSONDecoder()
314
+ found = None
315
+ pos = first
316
+ while pos >= 0:
317
+ try:
318
+ value, _ = decoder.raw_decode(text, pos)
319
+ except ValueError:
320
+ value = None
321
+ if isinstance(value, want):
322
+ found = value
323
+ pos = text.find(opener, pos + 1)
324
+ return found
304
325
 
305
326
 
306
327
  def _task_guardrail(pairs) -> str:
@@ -519,6 +540,12 @@ class CliBackend(Backend):
519
540
  return (1.0 if soft >= 0.8 else 0.0), soft, str(obj.get("reason", ""))[:200]
520
541
  except (ValueError, TypeError):
521
542
  pass
543
+ # A reply whose JSON lost its closing brace still carries the score
544
+ # (il2c night 11: 1 of 11 judge replies ended '..."' without '}').
545
+ scores = re.findall(r'"score"\s*:\s*([0-9]+(?:\.[0-9]+)?)', raw or "")
546
+ if scores:
547
+ soft = min(1.0, max(0.0, float(scores[-1])))
548
+ return (1.0 if soft >= 0.8 else 0.0), soft, "judge-score-only"
522
549
  return 0.0, 0.0, "judge-parse-failed"
523
550
 
524
551
  def reflect(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.113",
3
+ "version": "0.4.116",
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",