@suifei/dsh-ai-team 0.3.69 → 0.3.71

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.71 — 2026-11-11
4
+
5
+ - **【致命】工作台 #310 崩溃修复(用户实证)**:批量取消的忙碌标志 useState 被放在了 Workbench 的 Skeleton early-return **之后**——loading→ready 重渲染时 hooks 数量增多,触发 React #310 白屏。移到 early-return 之前的 state 区。渲染 E2E 的 React mock 同步加 **#310 守卫**:同一组件跨渲染 hooks 数量增多立即抛错(并在 0.3.69 类改动合入前即拦截)。
6
+
7
+ ## 0.3.70 — 2026-11-11
8
+
9
+ - **项目全局掌控:启动 / 停止 / 交接**(用户需求):新命令 `project.runState`(Human-only,账本留痕)——**停止**:PMO tick 与事件唤醒双门停止一切派发(正在执行的子任务自然完成,私信仍可);**启动**:空项目显式启动解除 P1a 等待门(Human 点启动即指令)或停止的项目继续开工(下一 tick ≤60s 生效)。新命令 `project.handoff`:按时序生成**交接文档**(Human 指令时序 + 任务全量状态/证据/QA + Thread 摘要 + 接手提示)写入工作目录 `docs/HANDOFF-<时间戳>.md`,账本留痕路径。项目头新增「项目运行 · 开/停止中」与「生成交接文档」按钮(chatGate/archive 旁)。bootstrap 下发 runState。
10
+
3
11
  ## 0.3.69 — 2026-11-11
4
12
 
5
13
  用户实证问题批(docs/phase1-2026-11-10/15-问题清单):
package/client.js CHANGED
@@ -222,6 +222,14 @@ window.__ModuleLoader__.load({
222
222
  chatGateOpened: 'Human 对话通道已开启:私信将直达成员下一轮。',
223
223
  chatGateClosedShort: 'Human 对话通道已关闭。',
224
224
  routingHint: '成员的原生会话由团队路由驱动,宿主不接受直接输入;请用下方私信与成员对话(下一轮生效)。',
225
+ runOn: '项目运行 · 开',
226
+ runOff: '项目运行 · 停止中',
227
+ runStateHint: '停止:当前子任务完成后停止派发(不再派发新任务/心跳/升级);启动:空项目开始或停止的项目继续开工',
228
+ runStarted: '项目已启动:PMO 将在下一个巡检周期开工。',
229
+ runStopped: '项目已停止:正在执行的子任务自然完成后不再派发。',
230
+ handoffBtn: '生成交接文档',
231
+ handoffHint: '按时序生成项目交接文档(Human 指令 + 任务全量),写入工作目录 docs/ 下',
232
+ handoffDone: '交接文档已生成:{path}',
225
233
  cancelAllPending: '取消全部待处理({n})',
226
234
  cancelAllHint: '批量取消当前全部待处理任务(逐卡取消并汇总结果)',
227
235
  cancelAllDone: '批量取消完成:成功 {done} 个,失败 {failed} 个。',
@@ -627,6 +635,14 @@ window.__ModuleLoader__.load({
627
635
  chatGateOpened: 'Human chat channel opened: DMs reach members next round.',
628
636
  chatGateClosedShort: 'Human chat channel closed.',
629
637
  routingHint: 'Member native sessions are driven by team routing; the host rejects direct input. Use the DM below to talk to a member (effective next round).',
638
+ runOn: 'Project run · on',
639
+ runOff: 'Project run · stopping',
640
+ runStateHint: 'Stop: finish the in-flight subtask then halt dispatch (no new tasks/heartbeats/escalations); Start: kick an empty project or resume a stopped one',
641
+ runStarted: 'Project started: PMO begins at the next tick.',
642
+ runStopped: 'Project stopped: in-flight subtasks finish, then dispatch halts.',
643
+ handoffBtn: 'Generate handoff doc',
644
+ handoffHint: 'Generate a chronological handoff document (Human instructions + all task info) into the workspace docs/ folder',
645
+ handoffDone: 'Handoff document written: {path}',
630
646
  cancelAllPending: 'Cancel all pending ({n})',
631
647
  cancelAllHint: 'Batch-cancel every pending task (one by one, with a summary)',
632
648
  cancelAllDone: 'Batch cancel done: {done} ok, {failed} failed.',
@@ -2613,6 +2629,9 @@ window.__ModuleLoader__.load({
2613
2629
  const [replyBase, setReplyBase] = React.useState(null);
2614
2630
  // R-06 决策回流高亮:主对话中被指认的 stream 消息 id。
2615
2631
  const [streamHighlight, setStreamHighlight] = React.useState(null);
2632
+ // P1b 批量取消的忙碌标志——必须位于 Skeleton early-return 之前
2633
+ // (React hooks 数量在渲染间必须恒定,否则 #310)。
2634
+ const [cancelAllBusy, setCancelAllBusy] = React.useState(false);
2616
2635
  // 自绘确认/输入对话框(替代原生 prompt/confirm,观感与宿主一致)。
2617
2636
  // dialog: { mode: 'confirm'|'prompt'|'choice', title, body, placeholder,
2618
2637
  // value, options, resolve } — resolve(false|null|字符串)。
@@ -2865,7 +2884,6 @@ window.__ModuleLoader__.load({
2865
2884
  const thread = threadFor(data, selectedTask?.id);
2866
2885
  const quadrants = deriveQuadrants(data);
2867
2886
  // P1b:批量取消全部待处理(逐卡 task.cancel,Human-only;汇总结果)。
2868
- const [cancelAllBusy, setCancelAllBusy] = React.useState(false);
2869
2887
  async function cancelAllPending(pendingTasks) {
2870
2888
  if (!Array.isArray(pendingTasks) || pendingTasks.length === 0) return;
2871
2889
  setCancelAllBusy(true);
@@ -2898,6 +2916,26 @@ window.__ModuleLoader__.load({
2898
2916
  const inboxItems = (data.inbox ?? []).filter((item) => !isInformationalInboxItem(item));
2899
2917
  // R-13bis:Human↔成员对话门(项目级开关,账本留痕)。
2900
2918
  const chatGateClosed = (project?.chatGate ?? 'open') === 'closed';
2919
+ // P6:项目运行态(启动/停止)+ 交接文档落盘。
2920
+ const runStopped = (project?.runState ?? 'running') === 'stopped';
2921
+ async function toggleRunState() {
2922
+ try {
2923
+ await runCommand('project.runState', { runState: runStopped ? 'running' : 'stopped' });
2924
+ say(runStopped ? t('runStarted') : t('runStopped'));
2925
+ await reloadData();
2926
+ } catch (error) {
2927
+ sayRight(tf(t, 'sendFailed', { message: error?.message ?? String(error) }));
2928
+ }
2929
+ }
2930
+ async function makeHandoff() {
2931
+ if (!project) return;
2932
+ try {
2933
+ const result = await runCommand('project.handoff', {});
2934
+ sayRight(tf(t, 'handoffDone', { path: result.filePath ?? '' }));
2935
+ } catch (error) {
2936
+ sayRight(tf(t, 'sendFailed', { message: error?.message ?? String(error) }));
2937
+ }
2938
+ }
2901
2939
  async function toggleChatGate() {
2902
2940
  try {
2903
2941
  await runCommand('project.chatGate', { gate: chatGateClosed ? 'open' : 'closed' });
@@ -3971,12 +4009,25 @@ window.__ModuleLoader__.load({
3971
4009
  title: t('chatGateHint'),
3972
4010
  'aria-pressed': !chatGateClosed,
3973
4011
  onClick: () => { void toggleChatGate(); },
3974
- }, !chatGateClosed ? t('chatGateOn') : t('chatGateOff'),
3975
- h('button', {
3976
- className: 'at-workspacebtn',
3977
- type: 'button',
3978
- title: t('archiveHint'),
3979
- onClick: () => { void archiveCurrentProject(); },
4012
+ }, !chatGateClosed ? t('chatGateOn') : t('chatGateOff'),
4013
+ h('button', {
4014
+ className: cx('at-pmobtn', !runStopped && 'at-pmo-on'),
4015
+ type: 'button',
4016
+ title: t('runStateHint'),
4017
+ 'aria-pressed': !runStopped,
4018
+ onClick: () => { void toggleRunState(); },
4019
+ }, !runStopped ? t('runOn') : t('runOff')),
4020
+ h('button', {
4021
+ className: 'at-workspacebtn',
4022
+ type: 'button',
4023
+ title: t('handoffHint'),
4024
+ onClick: () => { void makeHandoff(); },
4025
+ }, t('handoffBtn')),
4026
+ h('button', {
4027
+ className: 'at-workspacebtn',
4028
+ type: 'button',
4029
+ title: t('archiveHint'),
4030
+ onClick: () => { void archiveCurrentProject(); },
3980
4031
  }, t('archiveProject')))) : null,
3981
4032
  inInbox || inPeople ? null : h('div', { className: 'at-tabs', role: 'tablist', 'aria-label': t('tabsAria'), onKeyDown: tabKeyDown },
3982
4033
  h('button', {
package/index.js CHANGED
@@ -41,7 +41,7 @@ export const name = 'ai-team';
41
41
  /** The workbench only makes sense where the Web carrier exists. */
42
42
  export const inject = ['webServer', 'permissionPresets', 'sandboxPolicy'];
43
43
 
44
- const VERSION = '0.3.69';
44
+ const VERSION = '0.3.71';
45
45
  const PROJECT_ID = 'prj_main';
46
46
  const HUMAN_ID = 'mem_human';
47
47
 
@@ -386,6 +386,11 @@ export function apply(ctx, config = {}) {
386
386
  || null;
387
387
  const wakeFromResult = async (projectRuntime, result, actor = {}) => {
388
388
  if (projectRuntime === null || projectRuntime === undefined) return;
389
+ // P6 停止门(事件 hook 侧):stopped 项目停止**自动派发**;Human
390
+ // 主动触发的唤醒(如私信 member.message)仍放行——停止的是机器
391
+ // 驱动,不断 Human 通道。
392
+ const gateProject = projectRuntime.service.state.projects?.[projectRuntime.id];
393
+ if (gateProject !== undefined && gateProject.runState === 'stopped' && actor?.kind !== 'human') return;
389
394
  const plans = planWakes(projectRuntime.service.state, result, actor);
390
395
  if (plans.length === 0) return;
391
396
  // Window eviction: a key older than this horizon can no longer dedupe
@@ -499,6 +504,9 @@ export function apply(ctx, config = {}) {
499
504
  const state = projectRuntime.service.state;
500
505
  const project = state.projects?.[projectRuntime.id];
501
506
  if (project === undefined || project.pmoAuto === false || project.status === 'archived') return;
507
+ // P6 停止门:stopped 项目停止一切派发(补派/心跳/升级/continue 全停),
508
+ // 正在执行的回合自然完成;唤醒事件 hook 同样检查(见 wakeFromResult)。
509
+ if (project.runState === 'stopped') return;
502
510
  for (const member of Object.values(state.members ?? {})) {
503
511
  if (member.kind === 'agent' && typeof member.sessionId === 'string') {
504
512
  await titleMemberSession(projectRuntime, member);
@@ -608,11 +616,10 @@ export function apply(ctx, config = {}) {
608
616
  }
609
617
  return;
610
618
  }
611
- // P1:空项目(从未有过任何任务)不自动开工——新装用户配置完目录后
612
- // 被 PMO 自动建卡(用户实证:5 张卡违背「等我指令」预期)。等待
613
- // Human 首条指令(human_message → PMO 建卡链路保持不变)。
619
+ // P1a 门更新:空项目且未被 Human 显式启动 → 等待首条指令;显式启动
620
+ // (project.runState=running)即视为指令,解除等待。
614
621
  const hasAnyTaskHistory = Object.keys(state.tasks ?? {}).length > 0;
615
- if (!hasAnyTaskHistory) return;
622
+ if (!hasAnyTaskHistory && project.explicitStart !== true) return;
616
623
  const last = pmoLastKick.get(projectRuntime.id) ?? 0;
617
624
  if (now - last < 10 * 60_000) return;
618
625
  pmoLastKick.set(projectRuntime.id, now);
@@ -1,4 +1,5 @@
1
- import { existsSync, readFileSync, statSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
2
+ import pathDefault from 'node:path';
2
3
  import { ERRORS, fail } from '../domain/errors.js';
3
4
  import { findReportPath, parseDecisionQuestions } from './decision-report.js';
4
5
  import { ids } from '../domain/ids.js';
@@ -38,6 +39,63 @@ function mentionsHuman(body) {
38
39
  * `ledger.append` must update `ledger.state` before resolving (or provide a
39
40
  * synchronous state read after an awaited append).
40
41
  */
42
+ /**
43
+ * P6 交接文档:按时序拼接 Human 指令与全部任务关键信息,写入项目工作
44
+ * 目录(交付给别的工具继续开发);账本留痕记录路径。
45
+ */
46
+ // P6 交接文档生成:Human 指令时序 + 任务全量关键信息,Markdown 落盘。
47
+ function handoffMarkdown(state, project, nowMs) {
48
+ const line = (text) => String(text ?? '').replace(/\r?\n/g, '\n ');
49
+ const out = [];
50
+ out.push(`# 项目交接文档 — ${project.name}`);
51
+ out.push('');
52
+ out.push(`- 生成时间:${new Date(nowMs).toISOString()}`);
53
+ out.push(`- 项目 id:${project.id}`);
54
+ out.push(`- 目标:${project.goal ?? '(未填写)'}`);
55
+ out.push(`- 工作目录:${project.workspacePath}`);
56
+ out.push(`- 运行态:${project.runState === 'stopped' ? '已停止(交接前)' : '运行中'}`);
57
+ out.push('');
58
+ out.push('## 一、Human 指令时序(按账本顺序)');
59
+ out.push('');
60
+ const humanMessages = (state.stream ?? []).filter((entry) => entry.kind === 'human_message');
61
+ if (humanMessages.length === 0) out.push('(无 Human 指令记录)');
62
+ for (const entry of humanMessages) {
63
+ out.push(`- ${new Date(entry.at ?? 0).toISOString()} — ${line(entry.body)}`);
64
+ }
65
+ out.push('');
66
+ out.push('## 二、任务清单(含状态与验收要点)');
67
+ out.push('');
68
+ const tasks = Object.values(state.tasks ?? {}).filter((task) => task.tombstone !== true)
69
+ .sort((left, right) => (left.createdAt ?? 0) - (right.createdAt ?? 0));
70
+ if (tasks.length === 0) out.push('(无任务)');
71
+ for (const task of tasks) {
72
+ out.push(`### #${task.number ?? task.id} ${task.title} — ${task.status}`);
73
+ out.push(`- 结果定义:${line(task.resultDefinition)}`);
74
+ if (task.summary) out.push(`- 提交摘要:${line(task.summary)}`);
75
+ for (const ev of task.evidence ?? []) out.push(`- 证据(${ev.kind}):${line(ev.value)}`);
76
+ if (task.qaChecks?.length) out.push(`- QA 检查:${task.qaChecks.map((c) => `${c.passed ? '✔' : '✘'} ${line(c.text ?? '')}`).join(';')}`);
77
+ if (task.reason) out.push(`- 最近理由:${line(task.reason)}`);
78
+ out.push(`- 责任位:owner=${task.ownerId ?? '—'};assignee=${task.assigneeId ?? '—'};更新于 ${new Date(task.updatedAt ?? 0).toISOString()}`);
79
+ out.push('');
80
+ }
81
+ out.push('## 三、Thread 关键讨论(按任务)');
82
+ out.push('');
83
+ for (const [taskId, thread] of Object.entries(state.threads ?? {})) {
84
+ const entries = thread.entries ?? [];
85
+ if (entries.length === 0) continue;
86
+ out.push(`### Task ${taskId}`);
87
+ for (const entry of entries.slice(-20)) {
88
+ out.push(`- ${new Date(entry.at ?? 0).toISOString()} ${entry.author ?? entry.authorId ?? '—'}:${line(entry.body)}`);
89
+ }
90
+ out.push('');
91
+ }
92
+ out.push('## 四、接手提示');
93
+ out.push('');
94
+ out.push('- 以上内容来自插件账本投影(append-only,时序可信);接手工具可直接在工作目录继续开发。');
95
+ out.push('- 成员的 DSH 会话仍在,如需复用团队请保持项目 runState;如改用其他工具,可停止本项目。');
96
+ return out.join('\n') + '\n';
97
+ }
98
+
41
99
  export class TeamService {
42
100
  /**
43
101
  * @param {{ ledger: { state: any, append: (input: any) => Promise<any> }, now?: () => number, diag?: { append: (row: any) => any } }} options
@@ -86,6 +144,7 @@ export class TeamService {
86
144
  .map((p) => ({
87
145
  id: p.id, name: p.name, goal: p.goal ?? '', owner: p.ownerName ?? p.ownerMemberId ?? p.ownerId, workspacePath: p.workspacePath ?? '', pmoAuto: p.pmoAuto !== false, active: p.status !== 'archived',
88
146
  chatGate: p.chatGate === 'closed' ? 'closed' : 'open',
147
+ runState: p.runState === 'stopped' ? 'stopped' : 'running',
89
148
  }));
90
149
  const members = Object.values(state.members ?? {}).map((m) => ({
91
150
  id: m.id,
@@ -279,6 +338,8 @@ export class TeamService {
279
338
  case 'project.pmo.update': return await this.setProjectPmo(command, payload);
280
339
  case 'project.chatGate': return await this.setProjectChatGate(command, payload);
281
340
  case 'project.archive': return await this.setProjectArchive(command, payload);
341
+ case 'project.runState': return await this.setProjectRunState(command, payload);
342
+ case 'project.handoff': return await this.handoffProject(command, payload);
282
343
  case 'stream.post': return await this.postStream(command, payload);
283
344
  case 'member.add': return await this.addMember(command, payload);
284
345
  case 'member.bind': return await this.bindMemberSession(command, payload);
@@ -402,6 +463,41 @@ export class TeamService {
402
463
 
403
464
  // P4:项目归档(软删)——账本 append-only 纪律下不可物理删除;archived
404
465
  // 项目从工作台消失(bootstrap 过滤),成员的 DSH 会话不受影响。
466
+ // P6:项目运行态(启动/停止/交接)—— Human 的全局掌控面。
467
+ // 'stopped':PMO tick 停止派发(补派/心跳/升级/continue 全停),正在执行
468
+ // 的回合自然完成;'running'(默认):正常驱动。start 时 explicitStart=true
469
+ // 解除空项目的 P1a 等待门(Human 显式启动即指令)。
470
+ async setProjectRunState(command, payload) {
471
+ const projectId = command.projectId;
472
+ const project = this.state.projects?.[projectId];
473
+ if (project === undefined) fail(ERRORS.NOT_FOUND, `project ${String(projectId)} not found`);
474
+ const runState = payload.runState;
475
+ if (runState !== 'running' && runState !== 'stopped') fail(ERRORS.INVALID_ARGUMENT, 'runState must be running or stopped');
476
+ if (command.actor.kind !== 'human') fail(ERRORS.UNAUTHORIZED, 'only Human may change the project run state');
477
+ await this.append(command, 'project/run-state', { projectId, runState, reason: payload.reason ?? '' });
478
+ return { project: { ...project, runState, explicitStart: runState === 'running' ? true : project.explicitStart === true } };
479
+ }
480
+
481
+
482
+ async handoffProject(command, payload) {
483
+ const projectId = command.projectId;
484
+ const project = this.state.projects?.[projectId];
485
+ if (project === undefined) fail(ERRORS.NOT_FOUND, `project ${String(projectId)} not found`);
486
+ if (command.actor.kind !== 'human') fail(ERRORS.UNAUTHORIZED, 'only Human may request a handoff');
487
+ if (typeof project.workspacePath !== 'string' || project.workspacePath.trim() === '') {
488
+ fail(ERRORS.INVALID_STATE, '项目未配置工作目录,无法落盘交接文档');
489
+ }
490
+ const nowMs = this.now();
491
+ const markdown = handoffMarkdown(this.state, project, nowMs);
492
+ const docsDir = pathDefault.join(project.workspacePath, 'docs');
493
+ mkdirSync(docsDir, { recursive: true });
494
+ const stamp = new Date(nowMs).toISOString().replace(/[:T]/g, '-').slice(0, 19);
495
+ const filePath = pathDefault.join(docsDir, `HANDOFF-${stamp}.md`);
496
+ writeFileSync(filePath, markdown, 'utf8');
497
+ await this.append(command, 'project/handoff', { projectId, filePath, reason: payload.reason ?? '' });
498
+ return { project, filePath };
499
+ }
500
+
405
501
  async setProjectArchive(command, payload) {
406
502
  const projectId = command.projectId;
407
503
  const project = this.state.projects?.[projectId];
@@ -698,6 +698,35 @@ export function applyEvent(state, event) {
698
698
  });
699
699
  }
700
700
 
701
+ case 'project/run-state': {
702
+ const projectId = textOr(payload.projectId, event.projectId);
703
+ const project = state.projects?.[projectId];
704
+ if (project === undefined || (payload.runState !== 'running' && payload.runState !== 'stopped')) return advance(state, event);
705
+ return advance(state, event, {
706
+ projects: {
707
+ ...state.projects,
708
+ [projectId]: {
709
+ ...project,
710
+ runState: payload.runState,
711
+ // Human 显式启动 = 指令:解除空项目的 P1a 等待门。
712
+ explicitStart: project.explicitStart === true || payload.runState === 'running',
713
+ },
714
+ },
715
+ });
716
+ }
717
+
718
+ case 'project/handoff': {
719
+ const projectId = textOr(payload.projectId, event.projectId);
720
+ const project = state.projects?.[projectId];
721
+ if (project === undefined) return advance(state, event);
722
+ return advance(state, event, {
723
+ projects: {
724
+ ...state.projects,
725
+ [projectId]: { ...project, lastHandoffAt: event.at, lastHandoffPath: textOr(payload.filePath, null) },
726
+ },
727
+ });
728
+ }
729
+
701
730
  case 'project/workspace-changed': {
702
731
  const projectId = textOr(payload.projectId, event.projectId);
703
732
  const workspacePath = textOr(payload.workspacePath, null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.3.69",
3
+ "version": "0.3.71",
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",