@suifei/dsh-ai-team 0.4.144 → 0.4.146

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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.146 - 2026-12-01
4
+
5
+ - 人员池不再显示或统计归档项目;归档历史保留,旧页面不能继续向归档项目提交批量模型配置。侧栏新增「团队管理」,集中管理活动项目的成员与团队预设。感谢 @qq958691165 的反馈(#103)。
6
+ - 工作台启动遇到 503 时按已知的宿主连接与插件初始化错误分别提供排查步骤,来源不明时提示先检查宿主。README 增加桌面端排查步骤。反馈者遇到的 503 根因待确认。感谢 @Arnoldnuo 的反馈(#102)。
7
+
8
+ ## 0.4.145 - 2026-11-26
9
+
10
+ - PMO 自动决策不再给「不推荐」加分或按字母编号偏向选项,且「建议 A」可命中带括注的 A 选项。感谢 @Lamooner 的复现和建议(#99)。
11
+ - 新建和编辑项目共用工作目录选择兜底:识别宿主不提供当前表单可用选择器的情况,保留手填路径,并在后续选中目录后清除旧提示。不改宿主配置或 Workspace 注册时机。感谢 @ljyzww 的 Windows 反馈(#100)。
12
+
3
13
  ## 0.4.144 - 2026-11-21
4
14
 
5
15
  **SkillOpt:采纳闸门回归借自上游;评审记录把「评分解析失败」和「有效评分但没提升」分开**
package/README.md CHANGED
@@ -19,6 +19,13 @@
19
19
 
20
20
  <p align="center">觉得有用?点右上角 ⭐ <a href="https://github.com/suifei/dsh-ai-team">Star</a> 支持一下,也欢迎 <a href="https://github.com/suifei/dsh-ai-team/issues">提 issue</a> 和 <a href="https://github.com/suifei/dsh-ai-team/pulls">发 PR</a>。</p>
21
21
 
22
+ > [!IMPORTANT]
23
+ > **🤝 社区共创:文渊阁下一步怎么走,由社区决定。**
24
+ >
25
+ > 任何想法都欢迎[提到 Issue 里](https://github.com/suifei/dsh-ai-team/issues/new/choose):想加的功能、用着不顺的地方,或者你希望文渊阁以后长成什么样。**项目路线完全由本仓库的 Issue 驱动,不由维护者凭个人偏好改方向。**
26
+ >
27
+ > 每条建议都会认真看、公开反馈。社区讨论定下来的改动,由我们负责实现、验证和发版,发布结果也会回到对应的 Issue。
28
+
22
29
  > 文渊阁,藏修、校勘、纂辑之地。
23
30
  > 在这里,Human 不在环里逐条调度,而是在环上定方向、守信任、做最后那一步。
24
31
 
@@ -30,6 +37,10 @@
30
37
 
31
38
  ## 最近更新
32
39
 
40
+ - **归档项目与团队管理**(0.4.146)。人员池只汇总未归档项目的成员与任务,归档任务和会话仍可查阅。侧栏新增「团队管理」,集中管理项目成员和团队预设。感谢 [@qq958691165](https://github.com/qq958691165) 的反馈([#103](https://github.com/suifei/dsh-ai-team/issues/103))。
41
+ - **桌面端 503 排查**(0.4.146)。工作台按启动错误提供对应的排查提示,README 补充桌面端排查步骤。感谢 [@Arnoldnuo](https://github.com/Arnoldnuo) 的反馈([#102](https://github.com/suifei/dsh-ai-team/issues/102))。
42
+ - **PMO 决策排序**(0.4.145):不再把「不推荐」当作加分,也不按选项字母编号偏向某个方案;结构化建议可以匹配带括注的编号。感谢 [@Lamooner](https://github.com/Lamooner) 的复现和建议([#99](https://github.com/suifei/dsh-ai-team/issues/99))。
43
+ - **工作目录选择兜底**(0.4.145):新建和编辑项目时,如果宿主没有提供此表单可用的目录选择器,可直接粘贴或输入完整路径。不改宿主配置,也不会在提交项目前注册 Workspace(感谢 [@ljyzww](https://github.com/ljyzww) 的反馈,[#100](https://github.com/suifei/dsh-ai-team/issues/100))。
33
44
  - **输入框与 @成员**(0.4.120–0.4.123):输入框随内容长高、可拖大;能贴图、拖文件、选附件;@ 能点名具体成员,被 @ 的成员可以直接在主对话回你;成员可一键复制。文渊阁对话框和 DSH 标准会话(「文渊阁·PMO」)是同一套实现(感谢 [@xiuchuan666](https://github.com/xiuchuan666) 的反馈与建议,#65)。
34
45
  - **人才市场**(0.4.124–0.4.129):9 个内置团队、44 位内置人才,各自带看家技能。可以招聘、复制为可编辑、自建人才并装技能,也能把项目成员「存为人才」;新建项目时选团队,或从人才里挑人组新团队(源自 [@xiuchuan666](https://github.com/xiuchuan666) 在 #65 里的建议)。
35
46
  - **主理人只调度交付**(0.4.128):主理人不看产出,只问负责人做全没有;内容由验收人把关。
@@ -152,6 +163,12 @@ dsh --profile ai-team --no-open --port 33271
152
163
 
153
164
  > 插件只应安装在可信机器 / 可信 Workspace:成员以 `danger-full-access` 运行,且 profile patch 会把 sandbox / approval / permission 固定为 `danger-full-access / never`。普通 `desktop`/`web` profile 不安装时保持原有 preset roster。
154
165
 
166
+ ### 桌面端打开后提示 503
167
+
168
+ 先用上面的独立 `ai-team` profile 启动,并从终端给出的地址打开,不需要改原有桌面配置。若仍报 503,请在 Issue 里注明操作系统、DSH Desktop / Harness 和文渊阁版本、安装方式及 profile。能看到响应时,可附去掉查询参数的请求路径与 `error.code`;也可贴一行脱敏启动日志。请勿附上令牌、Cookie 或个人路径。
169
+
170
+ 如果是在 DSH 桌面应用里看到空白 503,顺手确认同一时刻普通工作区或设置能否打开。这有助于区分桌面宿主未就绪和文渊阁自身初始化失败;仅凭 503 不能判断是哪一种。
171
+
155
172
  ---
156
173
 
157
174
  ## 界面
@@ -176,7 +193,8 @@ dsh --profile ai-team --no-open --port 33271
176
193
  - **直接对话**:点击成员名字直接打开该 Agent 的 DSH 原生 Session;没有 session 会先激活;打不开时落到成员资料,资料里有「直接对话」按钮。
177
194
  - **成员任务**:成员资料里点「他的任务」,查看他 owner/assignee 的 Task。
178
195
  - **成员资料**:点「⋯」打开,按「资料 / 模型 / 技能 / 协作」分页签:改名、职责、个性、备忘;运行配方、提供商 / 模型 / 推理等级;技能与「进化」;交接人与私信。右上角是他的任务、直接对话、复制成员、存为人才、重置会话、重新蒸馏、离开团队。
179
- - **人员池**:按人汇总各项目里的成员卡片(负载、所在项目、跳转);「批量配置模型」一次给勾选的成员在其所在的全部项目设同一模型,卡片上的「配置模型」只改这一位。
196
+ - **人员池**:按人汇总进行中项目里的成员卡片(负载、所在项目、跳转);「批量配置模型」只改所选成员在未归档项目中的配置。归档不删除任务记录或成员的 DSH 会话。
197
+ - **团队管理**:从侧栏进入,切换未归档的项目,添加成员、打开成员资料或会话,也可查看、创建和删除自建团队预设。预设用于新建项目,不会改动现有团队。
180
198
 
181
199
  ---
182
200
 
@@ -330,6 +348,10 @@ round-19 DeepSeek + Zhipu 双 provider
330
348
 
331
349
  | 贡献者 | 贡献 | 带来的进展 |
332
350
  |---|---|---|
351
+ | [@qq958691165](https://github.com/qq958691165) | 归档项目的成员反馈、团队管理建议 [#103](https://github.com/suifei/dsh-ai-team/issues/103) | 人员池排除归档项目,侧栏集中管理项目成员与团队预设 |
352
+ | [@Arnoldnuo](https://github.com/Arnoldnuo) | 桌面端启动 503 反馈 [#102](https://github.com/suifei/dsh-ai-team/issues/102) | 工作台提供分情况的 503 提示,补充桌面端排查文档 |
353
+ | [@Lamooner](https://github.com/Lamooner) | PMO 决策反馈与建议 [#99](https://github.com/suifei/dsh-ai-team/issues/99) | 避免选中「不推荐」项,移除编号偏向并补充括注编号回归 |
354
+ | [@ljyzww](https://github.com/ljyzww) | Windows 目录选择反馈 [#100](https://github.com/suifei/dsh-ai-team/issues/100) | 新建和编辑项目共用目录选择失败提示,保留手填路径 |
333
355
  | [@xiuchuan666](https://github.com/xiuchuan666) | 反馈与建议 [#65](https://github.com/suifei/dsh-ai-team/issues/65) | 输入框长高可拖大、贴图拖文件、@ 点名成员(0.4.120–0.4.123);人才市场与在线人才库(0.4.124–0.4.131);团队扩编:超限排队、开发验收配对、空闲必派、写入范围、加人建议(0.4.140) |
334
356
  | [@TardisBooo](https://github.com/TardisBooo) | 代码 [#88](https://github.com/suifei/dsh-ai-team/pull/88) | 工具参数改为对象 JSON Schema,Grok 4.7 可用(0.4.139) |
335
357
 
package/client.js CHANGED
@@ -95,6 +95,9 @@ window.__ModuleLoader__.load({
95
95
  streamUp: '实时更新已恢复。',
96
96
  loadFailedTitle: '工作台不可达',
97
97
  loadFailedBody: 'bootstrap 接口(/ai-team)无法访问;请确认插件已启用后重试。',
98
+ bootFailure503: '文渊阁初始化失败。请查看宿主日志中的文渊阁启动错误,再点重试。',
99
+ bootConnection503: '宿主未提供插件所需的连接服务。请确认宿主已启动,并使用独立 ai-team profile。',
100
+ bootUnknown503: '宿主或文渊阁暂不可用。请先确认 DSH 的工作区或设置能否正常打开,再重试。',
98
101
  spike: 'AI Team',
99
102
  spikeTitle: '文渊阁 AI Team 工作台:修书、校勘、纂辑;方向、验收与账本。',
100
103
  navAria: '页面导航',
@@ -265,8 +268,8 @@ window.__ModuleLoader__.load({
265
268
  workspaceDialogTitle: '设置项目工作目录',
266
269
  workspaceDialogHint: 'Project 的成员会在这个目录里执行 Task;多个 Project 用不同目录隔离。',
267
270
  workspacePathPlaceholder: '例如 D:/work/my-project',
268
- workspacePickUnavailable: '当前宿主不支持目录选择,请手动输入路径。',
269
- workspacePickFailed: '目录选择失败,请手动输入路径。',
271
+ workspacePickUnavailable: '当前宿主的目录选择器不能用于此表单。请在「工作目录」中粘贴或输入完整路径。',
272
+ workspacePickFailed: '未能打开目录选择器。请重试,或在「工作目录」中粘贴或输入完整路径。',
270
273
  workspaceSave: '保存目录',
271
274
  projectCreate: '创建项目',
272
275
  projectCreated: '已创建项目 {name}。',
@@ -309,6 +312,7 @@ window.__ModuleLoader__.load({
309
312
  tcSkills: '技能', tcEmpty: '还没装技能(可选)', tcAddExisting: '从已有装', tcWriteOwn: '自写一份', tcImport: '导入 .md', tcPick: '选一个已有技能…', tcAdd: '加入', tcRemove: '移除',
310
313
  tcSkillName: '技能名(英文/数字/-)', tcSkillBody: '技能正文(SKILL.md)', tcSkillDup: '已经装了同名技能', tcSave: '存为我的人才', tcSaving: '保存中…',
311
314
  memberSaveAsTalent: '存为人才', tcFromMember: '从成员「{name}」存出:沿用它此刻的岗位、职责、性格与技能,可先修改再保存。', tcModelKept: '沿用模型:{model}', tcMissing: '这些技能找不到正文,没有带上:{skills}', tcDraftFailed: '读取成员草稿失败:{error}',
315
+ teamManagement: '团队管理', teamManageGoal: '管理当前项目成员,或为新项目准备团队预设。', teamActiveProject: '当前项目成员', teamPickProject: '切换活动项目以管理成员', teamNoActiveProject: '请选择一个未归档的项目。', teamPresets: '团队预设', teamPresetHint: '预设用于新建项目,不会更改已创建的项目。', teamNoPresets: '没有可用的团队预设。',
312
316
  projectTeam: '团队', teamCompose: '组一个新团队', teamComposeTitle: '组队', teamComposeHint: '从人才里挑人组队:同一人才可以招多位,给其中一位定为负责人(新项目的主理人)。', teamName: '团队名', teamDesc: '说明', teamMembers: '成员', teamPick: '从人才里挑人', teamAdd: '加入', teamLead: '负责人', teamEmptyPick: '还没挑人', teamSave: '保存团队', teamBack: '返回', teamDelete: '删除这个团队', teamDeleteConfirm: '删除自建团队「{name}」?团队文件会被删除,已用它建的项目和其中成员不受影响。', teamLoadFailed: '团队列表读取失败:{error}',
313
317
  talentEmpty: '没有符合条件的人才。',
314
318
  talentLoading: '正在读取人才市场…',
@@ -556,6 +560,9 @@ window.__ModuleLoader__.load({
556
560
  loading: 'Loading…',
557
561
  loadFailedTitle: 'Workbench unreachable',
558
562
  loadFailedBody: 'The bootstrap endpoint (/ai-team) cannot be reached; confirm the plugin is enabled and retry.',
563
+ bootFailure503: 'Wenyuan Pavilion could not initialize. Check its startup error in the host log and retry.',
564
+ bootConnection503: 'The host connection service is unavailable. Make sure the host is running and use the dedicated ai-team profile.',
565
+ bootUnknown503: 'The host or Wenyuan Pavilion is unavailable. Check whether a DSH workspace or Settings opens, then retry.',
559
566
  streamDown: 'Live updates stopped; the view may lag while the stream reconnects…',
560
567
  streamUp: 'Live updates are back.',
561
568
  spike: 'AI Team',
@@ -729,8 +736,8 @@ window.__ModuleLoader__.load({
729
736
  workspaceDialogTitle: 'Set Project workspace',
730
737
  workspaceDialogHint: 'Members run Tasks in this directory; separate Projects use separate directories.',
731
738
  workspacePathPlaceholder: 'e.g. D:/work/my-project',
732
- workspacePickUnavailable: 'This host has no directory picker; type a path.',
733
- workspacePickFailed: 'Directory picker failed; type a path.',
739
+ workspacePickUnavailable: 'The host’s directory picker is unavailable for this form. Paste or enter the full path in the Workspace field.',
740
+ workspacePickFailed: 'Could not open the directory picker. Retry, or paste or enter the full path in the Workspace field.',
734
741
  workspaceSave: 'Save directory',
735
742
  projectCreate: 'Create project',
736
743
  projectCreated: 'Created project {name}.',
@@ -773,6 +780,7 @@ window.__ModuleLoader__.load({
773
780
  tcSkills: 'Skills', tcEmpty: 'No skills yet (optional)', tcAddExisting: 'From existing', tcWriteOwn: 'Write one', tcImport: 'Import .md', tcPick: 'Pick an existing skill…', tcAdd: 'Add', tcRemove: 'Remove',
774
781
  tcSkillName: 'Skill name (a-z, 0-9, -)', tcSkillBody: 'Skill body (SKILL.md)', tcSkillDup: 'That skill name is already staged', tcSave: 'Save as my talent', tcSaving: 'Saving…',
775
782
  memberSaveAsTalent: 'Save as talent', tcFromMember: 'Saved from member “{name}”: its current role, duty, personality and skills are filled in; edit before saving.', tcModelKept: 'Keeps the model: {model}', tcMissing: 'These skills have no readable body and were left out: {skills}', tcDraftFailed: 'Could not read the member draft: {error}',
783
+ teamManagement: 'Team management', teamManageGoal: 'Manage the current project’s members or prepare team presets for new projects.', teamActiveProject: 'Current project members', teamPickProject: 'Switch active project to manage its members', teamNoActiveProject: 'Select a project that is not archived.', teamPresets: 'Team presets', teamPresetHint: 'Presets are used for new projects and do not change existing projects.', teamNoPresets: 'No available team presets.',
776
784
  projectTeam: 'Team', teamCompose: 'Compose a new team', teamComposeTitle: 'Compose a team', teamComposeHint: 'Pick talents into a team: the same talent can be hired more than once; mark one as the lead (the new project owner).', teamName: 'Team name', teamDesc: 'Description', teamMembers: 'Members', teamPick: 'Pick from talents', teamAdd: 'Add', teamLead: 'Lead', teamEmptyPick: 'Nobody picked yet', teamSave: 'Save team', teamBack: 'Back', teamDelete: 'Delete this team', teamDeleteConfirm: 'Delete your team “{name}”? Its file is removed; projects already created from it and their members are unaffected.', teamLoadFailed: 'Could not load teams: {error}',
777
785
  talentEmpty: 'No talent matches.',
778
786
  talentLoading: 'Loading the talent market…',
@@ -2374,7 +2382,7 @@ window.__ModuleLoader__.load({
2374
2382
  : h(EmptyState, { t, title: t('memberNoTasks'), body: t('memberNoTasksBody'), compact: true })));
2375
2383
  }
2376
2384
 
2377
- function LeftPanel({ t, data, projectId, scope, tab, inboxUnread, onBack, onInbox, onBoard, onPeople, peopleActive, onProject, onNewProject, onAgent, onAgentMore, onAgentChat, onAddAgent, onRecruit }) {
2385
+ function LeftPanel({ t, data, projectId, scope, tab, inboxUnread, onBack, onInbox, onBoard, onPeople, peopleActive, onTeam, onProject, onNewProject, onAgent, onAgentMore, onAgentChat, onAddAgent, onRecruit }) {
2378
2386
  const projects = data.projects.filter((project) => !project.archived);
2379
2387
  const activeAgents = data.agents.filter((agent) => agent.status !== 'retired');
2380
2388
  const talentAgents = data.agents.filter((agent) => agent.status === 'retired');
@@ -2402,6 +2410,12 @@ window.__ModuleLoader__.load({
2402
2410
  'aria-current': peopleActive ? 'page' : undefined,
2403
2411
  onClick: onPeople,
2404
2412
  }, h(Ico, { name: 'layers' }), h('span', null, t('people'))),
2413
+ h('button', {
2414
+ className: cx('at-navrow', scope === 'team' && 'at-on'),
2415
+ type: 'button',
2416
+ 'aria-current': scope === 'team' ? 'page' : undefined,
2417
+ onClick: onTeam,
2418
+ }, h(Ico, { name: 'users' }), h('span', null, t('teamManagement'))),
2405
2419
  ),
2406
2420
  h('div', { className: 'at-h' },
2407
2421
  h('span', null, t('projects')),
@@ -2441,6 +2455,45 @@ window.__ModuleLoader__.load({
2441
2455
  h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: () => onRecruit(agent) }, t('recruit')))))) : null);
2442
2456
  }
2443
2457
 
2458
+ function TeamManagementPage({ t, project, projects, agents, switching, onProject, onAdd, onAgent, onChat, onRecruit, teams, selectedTeam, onSelectTeam, error, onLoad, onCompose, onDelete }) {
2459
+ const active = agents.filter((agent) => agent.status !== 'retired');
2460
+ const retired = agents.filter((agent) => agent.status === 'retired');
2461
+ return h('div', { className: 'at-stream', role: 'region', 'aria-label': t('teamManagement') },
2462
+ h('div', { className: 'at-streaminner at-streamwide' },
2463
+ h('section', { className: 'at-pane', 'aria-labelledby': 'at-team-members' },
2464
+ h('h2', { id: 'at-team-members', className: 'at-panetitle' }, t('teamActiveProject')),
2465
+ h('label', { className: 'at-field' }, h('span', null, t('teamPickProject')),
2466
+ h('select', { value: project?.id ?? '', disabled: switching || !projects.length, onChange: (event) => {
2467
+ const next = projects.find((candidate) => candidate.id === event.target.value);
2468
+ if (next) void onProject(next);
2469
+ } }, !project ? h('option', { value: '' }, t('teamNoActiveProject')) : null,
2470
+ projects.map((candidate) => h('option', { key: candidate.id, value: candidate.id }, candidate.name)))),
2471
+ switching ? h('div', { className: 'at-modalmeta', role: 'status' }, t('loading')) : project ? h(React.Fragment, null,
2472
+ h('div', { className: 'at-tcpick' }, h('button', { className: 'at-btn at-btn-small at-btn-accent', type: 'button', onClick: onAdd }, withIco('plus', t('addAgent'), 12))),
2473
+ active.length ? h('div', { role: 'list', 'aria-label': t('agentsAria') }, active.map((agent) => h(AgentRow, { key: agent.id, t, agent, onAgent, onAgentMore: onAgent, onAgentChat: onChat }))) : h('div', { className: 'at-modalmeta' }, t('emptyColumn')),
2474
+ retired.length ? h('details', { className: 'at-archived' },
2475
+ h('summary', null, tf(t, 'talentPoolCount', { n: retired.length })),
2476
+ retired.map((agent) => h('div', { key: agent.id, className: 'at-agent at-talented' },
2477
+ h('div', { className: 'at-agentmeta' }, h('span', { className: 'at-agentname' }, agent.name)),
2478
+ h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: () => onRecruit(agent) }, t('recruit'))))) : null) : null),
2479
+ h('section', { className: 'at-pane', 'aria-labelledby': 'at-team-presets' },
2480
+ h('h2', { id: 'at-team-presets', className: 'at-panetitle' }, t('teamPresets')),
2481
+ h('p', { className: 'at-modalmeta' }, t('teamPresetHint')),
2482
+ h('div', { className: 'at-tcpick' },
2483
+ h('button', { className: 'at-btn at-btn-small at-btn-accent', type: 'button', onClick: onCompose }, withIco('users', t('teamCompose'), 12)),
2484
+ h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: onLoad }, withIco('sync', t('refresh'), 12)),
2485
+ selectedTeam?.source === 'user' ? h('button', { className: 'at-btn at-btn-small at-btn-danger', type: 'button', onClick: () => void onDelete(selectedTeam) }, withIco('close', t('teamDelete'), 12)) : null),
2486
+ error ? h('div', { className: 'at-modalerror', role: 'alert' }, error) : null,
2487
+ teams === null ? h('div', { className: 'at-modalmeta', role: 'status' }, t('talentLoading'))
2488
+ : teams.length ? h('label', { className: 'at-field' }, h('span', null, t('projectTeam')),
2489
+ h('select', { value: selectedTeam?.id ?? '', onChange: (event) => onSelectTeam(event.target.value) },
2490
+ teams.map((team) => h('option', { key: team.id, value: team.id }, team.name + ' · ' + team.members.length)))) : h('div', { className: 'at-modalmeta' }, t('teamNoPresets')),
2491
+ selectedTeam?.description ? h('p', { className: 'at-modalmeta' }, selectedTeam.description) : null,
2492
+ selectedTeam ? h('div', { className: 'at-marketgrid', role: 'list', 'aria-label': t('teamMembers') },
2493
+ selectedTeam.members.map((member) => h('div', { key: member.id, className: 'at-talent', role: 'listitem' },
2494
+ h(TalentInfo, { t, talent: member, lead: member.id === selectedTeam.lead })))) : null)));
2495
+ }
2496
+
2444
2497
  function ConvertForm({ t, project, task, thread, title, dod, onTitle, onDod, onCancel, onSubmit }) {
2445
2498
  const valid = Boolean(title.trim() && dod.trim());
2446
2499
  const onKeyDown = (event) => {
@@ -3571,6 +3624,16 @@ window.__ModuleLoader__.load({
3571
3624
  h(Ico, { name: 'down', size: 12 }), tf(t, 'streamUnseen', { count: unseen })));
3572
3625
  }
3573
3626
 
3627
+ async function bootstrapResponseError(response, t) {
3628
+ const label = 'HTTP ' + response.status + ' for /ai-team/api/bootstrap';
3629
+ if (response.status !== 503) return new Error(label);
3630
+ let code;
3631
+ try { code = (await response.json())?.error?.code; } catch {}
3632
+ if (code === 'BOOT_FAILED') return new Error(label + ' (' + code + '). ' + t('bootFailure503'));
3633
+ if (code === 'E_TRUST_FENCE_UNAVAILABLE') return new Error(label + ' (' + code + '). ' + t('bootConnection503'));
3634
+ return new Error(label + '. ' + t('bootUnknown503'));
3635
+ }
3636
+
3574
3637
  function Workbench({ t, ctx }) {
3575
3638
  const [phase, setPhase] = React.useState('loading');
3576
3639
  const [data, setData] = React.useState(null);
@@ -3650,7 +3713,10 @@ window.__ModuleLoader__.load({
3650
3713
  const [nTeam, setNTeam] = React.useState('');
3651
3714
  const [teamLoadError, setTeamLoadError] = React.useState('');
3652
3715
  const [teamComposeOpen, setTeamComposeOpen] = React.useState(false);
3653
- const selectedTeam = (teamList || []).find((entry) => entry.id === nTeam) || null;
3716
+ const [teamSwitching, setTeamSwitching] = React.useState(false);
3717
+ const projectSwitchRef = React.useRef(false);
3718
+ const teamLoadSeqRef = React.useRef(0);
3719
+ const selectedTeam = (teamList || []).find((entry) => !entry.broken && entry.id === nTeam) || null;
3654
3720
  const [workspaceOpen, setWorkspaceOpen] = React.useState(false);
3655
3721
  const [workspaceDraft, setWorkspaceDraft] = React.useState('');
3656
3722
  const [workspaceError, setWorkspaceError] = React.useState('');
@@ -3802,7 +3868,7 @@ window.__ModuleLoader__.load({
3802
3868
  headers: { accept: 'application/json' },
3803
3869
  signal: controller ? controller.signal : undefined,
3804
3870
  });
3805
- if (!response.ok) throw new Error('HTTP ' + response.status + ' for /ai-team/api/bootstrap');
3871
+ if (!response.ok) throw await bootstrapResponseError(response, t);
3806
3872
  const next = normalizePayload(await response.json());
3807
3873
  if (!next) throw new Error('invalid bootstrap payload');
3808
3874
  if (!alive || seq !== loadSeqRef.current) return;
@@ -4241,6 +4307,18 @@ window.__ModuleLoader__.load({
4241
4307
  loadPending();
4242
4308
  loadRisks();
4243
4309
  }
4310
+ function openTeam() {
4311
+ closeMobile();
4312
+ setMemberViewId(null);
4313
+ setScope('team');
4314
+ setThreadOpen(false);
4315
+ setNote('');
4316
+ void loadTeams(nTeam);
4317
+ }
4318
+ function openTeamComposer() {
4319
+ setTeamComposeOpen(true);
4320
+ void loadTalents();
4321
+ }
4244
4322
  function openPeople() {
4245
4323
  closeMobile();
4246
4324
  setMemberViewId(null);
@@ -4275,12 +4353,15 @@ window.__ModuleLoader__.load({
4275
4353
  setBoardFilter('all');
4276
4354
  setNote('');
4277
4355
  }
4278
- async function switchProject(next) {
4356
+ async function switchProject(next, nextScope = 'project') {
4279
4357
  closeMobile();
4280
- if (next.id === projectId && scope === 'project') return true;
4358
+ if (next.id === projectId && scope === nextScope) return true;
4359
+ if (projectSwitchRef.current) return false;
4360
+ projectSwitchRef.current = true;
4361
+ if (nextScope === 'team') setTeamSwitching(true);
4281
4362
  try {
4282
- await runCommand('project.activate', { projectId: next.id });
4283
- setScope('project');
4363
+ await runCommand('project.activate', { projectId: next.id }, projectId || next.id);
4364
+ if (nextScope !== 'team' || scopeRef.current === 'team') setScope(nextScope);
4284
4365
  setTab('main');
4285
4366
  setMemberViewId(null);
4286
4367
  setBoardFilter('all');
@@ -4293,6 +4374,9 @@ window.__ModuleLoader__.load({
4293
4374
  } catch (error) {
4294
4375
  say(tf(t, 'sendFailed', { message: error?.message ?? String(error) }));
4295
4376
  return false;
4377
+ } finally {
4378
+ projectSwitchRef.current = false;
4379
+ if (nextScope === 'team') setTeamSwitching(false);
4296
4380
  }
4297
4381
  }
4298
4382
  function openNewProject() {
@@ -4324,15 +4408,26 @@ window.__ModuleLoader__.load({
4324
4408
  }
4325
4409
  try {
4326
4410
  return { path: await service.pickDirectory(), error: null };
4327
- } catch {
4328
- return { error: 'failed', path: null };
4411
+ } catch (error) {
4412
+ // Harness rc.5 wraps the RPC error in a plain Error and retains only its message.
4413
+ const unavailable = error?.code === 'directory-picker/unavailable'
4414
+ || error?.message === 'directory picker failed: directoryPicker.pick needs the native capability; the composed picker serves "browse"';
4415
+ return { error: unavailable ? 'unavailable' : 'failed', path: null };
4329
4416
  }
4330
4417
  }
4331
- async function pickNewWorkspace() {
4418
+ async function applyWorkspacePick(setPath, setError) {
4332
4419
  const picked = await pickWorkspacePath();
4333
- if (picked.path) setNWorkspace(picked.path);
4334
- else if (picked.error === 'unavailable') setNError(t('workspacePickUnavailable'));
4335
- else if (picked.error === 'failed') setNError(t('workspacePickFailed'));
4420
+ const unavailable = t('workspacePickUnavailable');
4421
+ const failed = t('workspacePickFailed');
4422
+ if (picked.path) {
4423
+ setPath(picked.path);
4424
+ setError((previous) => previous === unavailable || previous === failed ? '' : previous);
4425
+ } else if (picked.error) {
4426
+ setError(picked.error === 'unavailable' ? unavailable : failed);
4427
+ }
4428
+ }
4429
+ async function pickNewWorkspace() {
4430
+ await applyWorkspacePick(setNWorkspace, setNError);
4336
4431
  }
4337
4432
  function openWorkspaceEditor() {
4338
4433
  setWorkspaceDraft(project?.workspacePath ?? '');
@@ -4340,10 +4435,7 @@ window.__ModuleLoader__.load({
4340
4435
  setWorkspaceOpen(true);
4341
4436
  }
4342
4437
  async function pickProjectWorkspace() {
4343
- const picked = await pickWorkspacePath();
4344
- if (picked.path) setWorkspaceDraft(picked.path);
4345
- else if (picked.error === 'unavailable') setWorkspaceError(t('workspacePickUnavailable'));
4346
- else if (picked.error === 'failed') setWorkspaceError(t('workspacePickFailed'));
4438
+ await applyWorkspacePick(setWorkspaceDraft, setWorkspaceError);
4347
4439
  }
4348
4440
  async function saveWorkspace() {
4349
4441
  if (!project || workspaceBusy || !workspaceDraft.trim()) return;
@@ -4362,19 +4454,25 @@ window.__ModuleLoader__.load({
4362
4454
  }
4363
4455
  /** 每次打开新建项目现取团队列表:刚组的队、刚改的 team.yml 立刻可选。select 留空表示沿用设置里的默认团队。 */
4364
4456
  async function loadTeams(select) {
4457
+ const seq = ++teamLoadSeqRef.current;
4365
4458
  setTeamLoadError('');
4366
4459
  try {
4367
4460
  const response = await fetch('/ai-team/api/teams', { headers: { accept: 'application/json' } });
4368
4461
  const body = await response.json().catch(() => null);
4369
4462
  if (!response.ok) throw new Error((body && body.error && body.error.message) || ('HTTP ' + response.status));
4463
+ if (seq !== teamLoadSeqRef.current) return;
4370
4464
  setTeamList(Array.isArray(body && body.teams) ? body.teams : []);
4371
- setNTeam(select || (body && body.defaultTeam) || 'default');
4465
+ const available = Array.isArray(body?.teams) ? body.teams.filter((entry) => !entry.broken) : [];
4466
+ const wanted = select || body?.defaultTeam || 'default';
4467
+ setNTeam(available.some((team) => team.id === wanted) ? wanted : available[0]?.id ?? '');
4372
4468
  } catch (error) {
4469
+ if (seq !== teamLoadSeqRef.current) return;
4373
4470
  setTeamList([]);
4374
4471
  setTeamLoadError(tf(t, 'teamLoadFailed', { error: (error && error.message) || String(error) }));
4375
4472
  }
4376
4473
  }
4377
- async function removeTeam(team) {
4474
+ async function removeTeam(team, onError = setNError) {
4475
+ if (team.source !== 'user') return;
4378
4476
  if (!(await askConfirm(t('teamDelete'), tf(t, 'teamDeleteConfirm', { name: team.name })))) return;
4379
4477
  try {
4380
4478
  const response = await fetch('/ai-team/api/teams/delete', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: team.id }) });
@@ -4382,7 +4480,7 @@ window.__ModuleLoader__.load({
4382
4480
  if (!response.ok) throw new Error((body && body.error && body.error.message) || ('HTTP ' + response.status));
4383
4481
  await loadTeams();
4384
4482
  } catch (error) {
4385
- setNError((error && error.message) || String(error));
4483
+ onError((error && error.message) || String(error));
4386
4484
  }
4387
4485
  }
4388
4486
  async function createProject() {
@@ -5243,12 +5341,14 @@ window.__ModuleLoader__.load({
5243
5341
 
5244
5342
  const inInbox = scope === 'inbox';
5245
5343
  const inPeople = scope === 'people';
5344
+ const inTeam = scope === 'team';
5345
+ const teamProject = project && project.id === projectId && data.project?.id === projectId && !project.archived ? project : null;
5246
5346
  const memberViewAgent = data.agents.find((agent) => agent.id === memberViewId) ?? null;
5247
5347
  const memberViewTasks = memberViewAgent === null ? [] : tasks.filter((task) => task.ownerId === memberViewAgent.id || task.assigneeId === memberViewAgent.id);
5248
- const headerTitle = inPeople ? t('peopleTitle') : inInbox ? t('inboxTitle') : project ? '# ' + project.name : t('noProject');
5348
+ const headerTitle = inTeam ? t('teamManagement') : inPeople ? t('peopleTitle') : inInbox ? t('inboxTitle') : project ? '# ' + project.name : t('noProject');
5249
5349
  // 只拿到名字的地方(消息、人员池、批量配置)按这张表找成员的头像参数。
5250
5350
  rememberAvatars(data?.agents, talents);
5251
- const headerGoal = inPeople ? t('peopleGoal') : inInbox ? t('inboxGoal') : (project?.goal ?? '');
5351
+ const headerGoal = inTeam ? t('teamManageGoal') : inPeople ? t('peopleGoal') : inInbox ? t('inboxGoal') : (project?.goal ?? '');
5252
5352
  const unread = inboxUnread > 99 ? '99+' : inboxUnread;
5253
5353
 
5254
5354
  const leftProps = {
@@ -5262,6 +5362,7 @@ window.__ModuleLoader__.load({
5262
5362
  onInbox: switchInbox,
5263
5363
  onBoard: switchBoard,
5264
5364
  onPeople: openPeople,
5365
+ onTeam: openTeam,
5265
5366
  peopleActive: scope === 'people',
5266
5367
  onProject: switchProject,
5267
5368
  onNewProject: () => { closeMobile(); openNewProject(); },
@@ -5272,7 +5373,15 @@ window.__ModuleLoader__.load({
5272
5373
  onRecruit: (agent) => { closeMobile(); recruit(agent); },
5273
5374
  };
5274
5375
 
5275
- const body = inPeople
5376
+ const body = inTeam
5377
+ ? h(TeamManagementPage, {
5378
+ t, project: teamProject, projects: data.projects.filter((entry) => !entry.archived), agents: teamProject ? data.agents : [],
5379
+ switching: teamSwitching, onProject: (next) => switchProject(next, 'team'),
5380
+ onAdd: openAddAgent, onAgent: openProfile, onChat: openAgentChat, onRecruit: recruit,
5381
+ teams: teamList?.filter((entry) => !entry.broken) ?? null, selectedTeam, error: teamLoadError, onSelectTeam: setNTeam,
5382
+ onLoad: () => void loadTeams(nTeam), onCompose: openTeamComposer, onDelete: (team) => removeTeam(team, setTeamLoadError),
5383
+ })
5384
+ : inPeople
5276
5385
  ? h(PeoplePage, {
5277
5386
  t,
5278
5387
  people: peopleData,
@@ -5454,7 +5563,7 @@ window.__ModuleLoader__.load({
5454
5563
  h('details', { className: 'at-mobile', ref: mobileRef },
5455
5564
  h('summary', { className: 'at-mobilesummary', 'aria-label': t('menuAria') }, h(Ico, { name: 'menu', size: 14 }), h('span', null, t('menu'))),
5456
5565
  h('div', { className: 'at-mobilepop' }, h(LeftPanel, leftProps))),
5457
- h('span', { className: 'at-topproject', title: headerTitle }, inInbox ? t('inboxTitle') + (unread ? ' · ' + unread : '') : (project?.name ?? ''))),
5566
+ h('span', { className: 'at-topproject', title: headerTitle }, inInbox ? t('inboxTitle') + (unread ? ' · ' + unread : '') : inTeam ? t('teamManagement') : (project?.name ?? ''))),
5458
5567
  h(ToastStack, { t, toasts, onClose: (id) => setToasts((prev) => prev.filter((toast) => toast.id !== id)) }),
5459
5568
  h('div', { className: cx('at-grid', threadOpen && selectedTask && 'at-withthread') },
5460
5569
  h('aside', { className: 'at-left', role: 'region', 'aria-label': t('projectsAria') }, h(LeftPanel, leftProps)),
@@ -5462,7 +5571,7 @@ window.__ModuleLoader__.load({
5462
5571
  h('header', { className: 'at-chead' },
5463
5572
  h('div', { className: 'at-title', title: headerTitle }, headerTitle),
5464
5573
  headerGoal ? h('div', { className: 'at-goal', title: headerGoal }, headerGoal) : null,
5465
- !inInbox && !inPeople && project ? h('div', { className: 'at-workspacebar' },
5574
+ !inInbox && !inPeople && !inTeam && project ? h('div', { className: 'at-workspacebar' },
5466
5575
  h('span', { className: 'at-workspacepath', title: project.workspacePath || t('workspaceHint') },
5467
5576
  project.workspacePath ? t('workspace') + ':' + project.workspacePath : t('workspaceUnset')),
5468
5577
  h('button', { className: 'at-workspacebtn', type: 'button', onClick: openWorkspaceEditor }, project.workspacePath ? t('workspaceChange') : t('workspaceChoose')),
@@ -5492,7 +5601,7 @@ window.__ModuleLoader__.load({
5492
5601
  title: t('archiveHint'),
5493
5602
  onClick: () => { void archiveCurrentProject(); },
5494
5603
  }, t('archiveProject'))) : null,
5495
- inInbox || inPeople ? null : h('div', { className: 'at-tabs', role: 'tablist', 'aria-label': t('tabsAria'), onKeyDown: tabKeyDown },
5604
+ inInbox || inPeople || inTeam ? null : h('div', { className: 'at-tabs', role: 'tablist', 'aria-label': t('tabsAria'), onKeyDown: tabKeyDown },
5496
5605
  h('button', {
5497
5606
  className: cx('at-tab', tab === 'main' && 'at-on'),
5498
5607
  type: 'button',
@@ -5813,7 +5922,7 @@ window.__ModuleLoader__.load({
5813
5922
  : h('select', { value: nTeam, onChange: (event) => setNTeam(event.target.value) }, teamList.filter((entry) => !entry.broken).map((entry) => h('option', { key: entry.id, value: entry.id }, entry.name + '(' + entry.members.length + ')' + (entry.source === 'user' ? ' · ' + t('talentUser') : ''))))),
5814
5923
  teamLoadError ? h('div', { className: 'at-modalerror', role: 'alert' }, teamLoadError) : null,
5815
5924
  h('div', { className: 'at-tcpick' },
5816
- h('button', { className: 'at-btn at-btn-small at-btn-accent', type: 'button', onClick: () => { setTeamComposeOpen(true); loadTalents(); } }, withIco('users', t('teamCompose'), 12)),
5925
+ h('button', { className: 'at-btn at-btn-small at-btn-accent', type: 'button', onClick: openTeamComposer }, withIco('users', t('teamCompose'), 12)),
5817
5926
  selectedTeam && selectedTeam.source === 'user' ? h('button', { className: 'at-btn at-btn-small at-btn-danger', type: 'button', onClick: () => void removeTeam(selectedTeam) }, withIco('close', t('teamDelete'), 12)) : null)),
5818
5927
  // 右栏:选中团队的成员卡片(名字、岗位、职责、简介、技能;负责人标出来)。
5819
5928
  h('div', { className: 'at-pane' },
package/index.js CHANGED
@@ -67,7 +67,7 @@ import { registerHostSessionGate } from './lib/runtime/host-session-gate.js';
67
67
  import { createActivationBudget } from './lib/runtime/activation-budget.js';
68
68
  import { blocksActivation, probeProviderRegistration } from './lib/runtime/subagent-probe.js';
69
69
  import { isRuntimeUnavailableFailure, resolveSubagentProviderName } from './lib/runtime/subagent-provider.js';
70
- import { aggregatePeople } from './lib/host/people-view.js';
70
+ import { aggregatePeople, peopleProjectIsArchived } from './lib/host/people-view.js';
71
71
  import { riskView } from './lib/host/risk-view.js';
72
72
  import { weeklyView } from './lib/host/weekly-view.js';
73
73
  import { isInformationalThreadMention } from './lib/domain/inbox.js';
@@ -2738,6 +2738,7 @@ export function apply(ctx, config = {}) {
2738
2738
  const revived = [];
2739
2739
  const skipped = [];
2740
2740
  for (const runtime of runtimeEntries) {
2741
+ if (peopleProjectIsArchived(booted.registry.list().find((entry) => entry.id === runtime.id), runtime)) continue;
2741
2742
  for (const member of Object.values(runtime.service.state.members ?? {})) {
2742
2743
  if (member.kind !== 'agent' || member.status === 'retired') continue;
2743
2744
  const eligible = includeAll ? member.status === 'failed' : isRuntimeUnavailableFailure(member);
@@ -3070,6 +3071,11 @@ export function apply(ctx, config = {}) {
3070
3071
  if (typeof body?.type !== 'string' || body.type === '') {
3071
3072
  return send(res, { error: { code: 'E_INVALID_ARGUMENT', message: 'command type is required' } }, 400);
3072
3073
  }
3074
+ // 人员池可能还持有归档前的快照,不允许旧的批量配置修改归档项目。
3075
+ if (body.type === 'member.config.update' &&
3076
+ peopleProjectIsArchived(booted.registry.list().find((entry) => entry.id === runtime.id), runtime)) {
3077
+ return send(res, { error: { code: 'E_INVALID_STATE', message: 'project is archived' } }, 409);
3078
+ }
3073
3079
  // 归档保护在实际的全局清单上判定(registry 跨项目;service 只见
3074
3080
  // 自己的账本,旧实现在 service 内判定导致所有归档被误拒)。
3075
3081
  if (body.type === 'project.archive' && body.payload?.archived !== false) {
@@ -1,120 +1,127 @@
1
- /**
2
- * 人员池只读聚合(11-管理视角与信息架构 §2):遍历各 Project 账本的
3
- * members/tasks,按姓名把"同一个人在各项目的身份"聚成一行。
4
- * 不产生任何新数据——输入是既有账本投影,输出是纯视图。
5
- *
6
- * 同名即同一人:默认花名册同名同人;自建成员重名视为同一团队身份(文档化
7
- * 于 docs/11 §5)。可选 `aliases`(name → personId 视图层绑定,R-17)在
8
- * 同名聚合之上生效。
9
- */
10
-
11
- import { isTaskBlocked } from '../ledger/fold.js';
12
-
13
- const ACTIVE_TASK_STATUSES = new Set(['pending', 'in_progress', 'pending_acceptance']);
14
-
15
- /**
16
- * @param {Array<{id:string,name:string}>} registryEntries
17
- * @param {Array<{id:string,service:{state:any}}>} runtimes
18
- * @param {{ aliases?: Record<string,string> }} [options]
19
- * @returns {Array<{name:string,role:string,projects:Array,failures:number,activeTasks:number}>}
20
- */
21
- export function aggregatePeople(registryEntries, runtimes, options = {}) {
22
- const aliases = options.aliases ?? null;
23
- const people = new Map();
24
- // 别名文件是手工/旧版本可写的,值不一定是字符串:直接 .startsWith 会让 /api/people 500。
25
- const aliasOf = (name) => {
26
- const raw = aliases !== null && Object.prototype.hasOwnProperty.call(aliases, name) ? aliases[name] : null;
27
- return typeof raw === 'string' && raw !== '' ? raw : null;
28
- };
29
- const bucketOf = (name) => {
30
- // 别名的目标可以是 `person:<id>`(真正的 personId)、`name:<名字>`,或
31
- // 历史数据里的裸名字。裸名字必须归一到 `name:<名字>`——否则「X → 白砚」
32
- // 会让 X 落到 `person:白砚`,而白砚本人是 `name:白砚`,两行永远合不到一起。
33
- const alias = aliasOf(name);
34
- if (alias === null) return `name:${name}`;
35
- if (alias.startsWith('person:') || alias.startsWith('name:')) return alias;
36
- return `name:${alias}`;
37
- };
38
- // 合并出来的那一行必须叫**目标**的名字:它由遍历顺序里第一个成员创建,若直接用
39
- // 该成员的原始名字,「百里 → 白砚」会合成一行却显示成「百里」。
40
- const displayNameOf = (name) => {
41
- const alias = aliasOf(name);
42
- return alias !== null && alias.startsWith('name:') ? alias.slice('name:'.length) : name;
43
- };
44
- for (const runtime of runtimes) {
45
- const projectName = registryEntries.find((project) => project.id === runtime.id)?.name ?? runtime.id;
46
- const state = runtime.service?.state;
47
- if (state === undefined || state === null) continue;
48
- // 本项目的活跃任务计数:按 owner/assignee 两个责任位累计,并按状态
49
- // 分解(R-10 成员负载:进行中/待验收/受阻)。
50
- const loadByMember = new Map();
51
- for (const task of Object.values(state.tasks ?? {})) {
52
- if (task.tombstone === true || !ACTIVE_TASK_STATUSES.has(task.status)) continue;
53
- const bucketKey = task.status === 'in_progress' ? 'inProgress'
54
- : task.status === 'pending_acceptance' ? 'pendingAcceptance'
55
- : 'pending';
56
- for (const memberId of [task.ownerId, task.assigneeId]) {
57
- if (typeof memberId !== 'string' || memberId === '') continue;
58
- const load = loadByMember.get(memberId) ?? { activeTasks: 0, inProgress: 0, pendingAcceptance: 0, pending: 0, blocked: 0 };
59
- load.activeTasks += 1;
60
- if (bucketKey === 'inProgress') load.inProgress += 1;
61
- else if (bucketKey === 'pendingAcceptance') load.pendingAcceptance += 1;
62
- else load.pending += 1;
63
- if (isTaskBlocked(state, task) === true) load.blocked += 1;
64
- loadByMember.set(memberId, load);
65
- }
66
- }
67
- for (const member of Object.values(state.members ?? {})) {
68
- if (member.kind === 'human') continue;
69
- // 空串名不吃 ?? 兜底(fold 允许空名成员;空名各自按 id 独立成行)。
70
- const memberName = member.name || member.id;
71
- const bucket = bucketOf(memberName);
72
- const entry = people.get(bucket) ?? {
73
- name: displayNameOf(memberName),
74
- role: member.role ?? '',
75
- projects: [],
76
- failures: 0,
77
- activeTasks: 0,
78
- };
79
- if (entry.role === '' && member.role) entry.role = member.role;
80
- const load = loadByMember.get(member.id) ?? { activeTasks: 0, inProgress: 0, pendingAcceptance: 0, pending: 0, blocked: 0 };
81
- // 同人同项目出现多个 memberId(如离职后重入职的新会话 id):合并为
82
- // 一行负载,memberIds 保留全部身份 id(兼容字段 memberId 取首个)。
83
- const existingProjectRow = entry.projects.find((row) => row.projectId === runtime.id);
84
- if (existingProjectRow !== undefined) {
85
- for (const key of ['activeTasks', 'inProgress', 'pendingAcceptance', 'pending', 'blocked']) {
86
- existingProjectRow[key] = (existingProjectRow[key] ?? 0) + load[key];
87
- }
88
- existingProjectRow.status = member.status ?? existingProjectRow.status;
89
- existingProjectRow.sessionId = member.sessionId ?? existingProjectRow.sessionId;
90
- existingProjectRow.memberIds = [...new Set([...(existingProjectRow.memberIds ?? [existingProjectRow.memberId].filter(Boolean)), member.id])];
91
- entry.failures += member.lastFailure !== undefined && member.lastFailure !== null ? 1 : 0;
92
- entry.activeTasks += load.activeTasks;
93
- people.set(bucket, entry);
94
- continue;
95
- }
96
- entry.projects.push({
97
- projectId: runtime.id,
98
- projectName,
99
- status: member.status ?? 'idle',
100
- sessionId: member.sessionId ?? null,
101
- memberIds: [member.id],
102
- talentPool: member.talentPool === true,
103
- attempts: member.attempts ?? 0,
104
- lastFailure: member.lastFailure ?? null,
105
- activeTasks: load.activeTasks,
106
- inProgress: load.inProgress,
107
- pendingAcceptance: load.pendingAcceptance,
108
- pending: load.pending,
109
- blocked: load.blocked,
110
- });
111
- if (member.lastFailure !== undefined && member.lastFailure !== null) entry.failures += 1;
112
- entry.activeTasks += load.activeTasks;
113
- people.set(bucket, entry);
114
- }
115
- }
116
- return [...people.values()].sort((left, right) => left.name.localeCompare(right.name));
117
- }
118
- // 语义备注:failures 计的是"当前仍带 lastFailure 的项目数"——member/recovered
119
- // 不清 lastFailure(保留最近一次失败供展示),康复成员会继续计入;这是展示
120
- // 口径而非存活判定(存活以 status 为准)。
1
+ /**
2
+ * 人员池只读聚合(11-管理视角与信息架构 §2):遍历各 Project 账本的
3
+ * members/tasks,按姓名把"同一个人在各项目的身份"聚成一行。
4
+ * 不产生任何新数据——输入是既有账本投影,输出是纯视图。
5
+ *
6
+ * 同名即同一人:默认花名册同名同人;自建成员重名视为同一团队身份(文档化
7
+ * 于 docs/11 §5)。可选 `aliases`(name → personId 视图层绑定,R-17)在
8
+ * 同名聚合之上生效。
9
+ */
10
+
11
+ import { isTaskBlocked } from '../ledger/fold.js';
12
+
13
+ /** 归档历史仍可读取,不参与日常人员池与批量操作。 */
14
+ export function peopleProjectIsArchived(project, runtime) {
15
+ return project?.archived === true || runtime.service?.state?.projects?.[runtime.id]?.status === 'archived';
16
+ }
17
+
18
+ const ACTIVE_TASK_STATUSES = new Set(['pending', 'in_progress', 'pending_acceptance']);
19
+
20
+ /**
21
+ * @param {Array<{id:string,name:string,archived?:boolean}>} registryEntries
22
+ * @param {Array<{id:string,service:{state:any}}>} runtimes
23
+ * @param {{ aliases?: Record<string,string> }} [options]
24
+ * @returns {Array<{name:string,role:string,projects:Array,failures:number,activeTasks:number}>}
25
+ */
26
+ export function aggregatePeople(registryEntries, runtimes, options = {}) {
27
+ const aliases = options.aliases ?? null;
28
+ const people = new Map();
29
+ // 别名文件是手工/旧版本可写的,值不一定是字符串:直接 .startsWith 会让 /api/people 500。
30
+ const aliasOf = (name) => {
31
+ const raw = aliases !== null && Object.prototype.hasOwnProperty.call(aliases, name) ? aliases[name] : null;
32
+ return typeof raw === 'string' && raw !== '' ? raw : null;
33
+ };
34
+ const bucketOf = (name) => {
35
+ // 别名的目标可以是 `person:<id>`(真正的 personId)、`name:<名字>`,或
36
+ // 历史数据里的裸名字。裸名字必须归一到 `name:<名字>`——否则「X → 白砚」
37
+ // 会让 X 落到 `person:白砚`,而白砚本人是 `name:白砚`,两行永远合不到一起。
38
+ const alias = aliasOf(name);
39
+ if (alias === null) return `name:${name}`;
40
+ if (alias.startsWith('person:') || alias.startsWith('name:')) return alias;
41
+ return `name:${alias}`;
42
+ };
43
+ // 合并出来的那一行必须叫**目标**的名字:它由遍历顺序里第一个成员创建,若直接用
44
+ // 该成员的原始名字,「百里 → 白砚」会合成一行却显示成「百里」。
45
+ const displayNameOf = (name) => {
46
+ const alias = aliasOf(name);
47
+ return alias !== null && alias.startsWith('name:') ? alias.slice('name:'.length) : name;
48
+ };
49
+ for (const runtime of runtimes) {
50
+ const project = registryEntries.find((entry) => entry.id === runtime.id);
51
+ if (peopleProjectIsArchived(project, runtime)) continue;
52
+ const projectName = project?.name ?? runtime.id;
53
+ const state = runtime.service?.state;
54
+ if (state === undefined || state === null) continue;
55
+ // 本项目的活跃任务计数:按 owner/assignee 两个责任位累计,并按状态
56
+ // 分解(R-10 成员负载:进行中/待验收/受阻)。
57
+ const loadByMember = new Map();
58
+ for (const task of Object.values(state.tasks ?? {})) {
59
+ if (task.tombstone === true || !ACTIVE_TASK_STATUSES.has(task.status)) continue;
60
+ const bucketKey = task.status === 'in_progress' ? 'inProgress'
61
+ : task.status === 'pending_acceptance' ? 'pendingAcceptance'
62
+ : 'pending';
63
+ for (const memberId of [task.ownerId, task.assigneeId]) {
64
+ if (typeof memberId !== 'string' || memberId === '') continue;
65
+ const load = loadByMember.get(memberId) ?? { activeTasks: 0, inProgress: 0, pendingAcceptance: 0, pending: 0, blocked: 0 };
66
+ load.activeTasks += 1;
67
+ if (bucketKey === 'inProgress') load.inProgress += 1;
68
+ else if (bucketKey === 'pendingAcceptance') load.pendingAcceptance += 1;
69
+ else load.pending += 1;
70
+ if (isTaskBlocked(state, task) === true) load.blocked += 1;
71
+ loadByMember.set(memberId, load);
72
+ }
73
+ }
74
+ for (const member of Object.values(state.members ?? {})) {
75
+ if (member.kind === 'human') continue;
76
+ // 空串名不吃 ?? 兜底(fold 允许空名成员;空名各自按 id 独立成行)。
77
+ const memberName = member.name || member.id;
78
+ const bucket = bucketOf(memberName);
79
+ const entry = people.get(bucket) ?? {
80
+ name: displayNameOf(memberName),
81
+ role: member.role ?? '',
82
+ projects: [],
83
+ failures: 0,
84
+ activeTasks: 0,
85
+ };
86
+ if (entry.role === '' && member.role) entry.role = member.role;
87
+ const load = loadByMember.get(member.id) ?? { activeTasks: 0, inProgress: 0, pendingAcceptance: 0, pending: 0, blocked: 0 };
88
+ // 同人同项目出现多个 memberId(如离职后重入职的新会话 id):合并为
89
+ // 一行负载,memberIds 保留全部身份 id(兼容字段 memberId 取首个)。
90
+ const existingProjectRow = entry.projects.find((row) => row.projectId === runtime.id);
91
+ if (existingProjectRow !== undefined) {
92
+ for (const key of ['activeTasks', 'inProgress', 'pendingAcceptance', 'pending', 'blocked']) {
93
+ existingProjectRow[key] = (existingProjectRow[key] ?? 0) + load[key];
94
+ }
95
+ existingProjectRow.status = member.status ?? existingProjectRow.status;
96
+ existingProjectRow.sessionId = member.sessionId ?? existingProjectRow.sessionId;
97
+ existingProjectRow.memberIds = [...new Set([...(existingProjectRow.memberIds ?? [existingProjectRow.memberId].filter(Boolean)), member.id])];
98
+ entry.failures += member.lastFailure !== undefined && member.lastFailure !== null ? 1 : 0;
99
+ entry.activeTasks += load.activeTasks;
100
+ people.set(bucket, entry);
101
+ continue;
102
+ }
103
+ entry.projects.push({
104
+ projectId: runtime.id,
105
+ projectName,
106
+ status: member.status ?? 'idle',
107
+ sessionId: member.sessionId ?? null,
108
+ memberIds: [member.id],
109
+ talentPool: member.talentPool === true,
110
+ attempts: member.attempts ?? 0,
111
+ lastFailure: member.lastFailure ?? null,
112
+ activeTasks: load.activeTasks,
113
+ inProgress: load.inProgress,
114
+ pendingAcceptance: load.pendingAcceptance,
115
+ pending: load.pending,
116
+ blocked: load.blocked,
117
+ });
118
+ if (member.lastFailure !== undefined && member.lastFailure !== null) entry.failures += 1;
119
+ entry.activeTasks += load.activeTasks;
120
+ people.set(bucket, entry);
121
+ }
122
+ }
123
+ return [...people.values()].sort((left, right) => left.name.localeCompare(right.name));
124
+ }
125
+ // 语义备注:failures 计的是"当前仍带 lastFailure 的项目数"——member/recovered
126
+ // 不清 lastFailure(保留最近一次失败供展示),康复成员会继续计入;这是展示
127
+ // 口径而非存活判定(存活以 status 为准)。
package/lib/host/pmo.js CHANGED
@@ -10,15 +10,16 @@ import { STALLED_MEMBER_STATUSES, dependenciesDone, teamRoles, writeScopeConflic
10
10
  */
11
11
 
12
12
  const LOW_VALUE = /最小|暂缓|延后|不做|暂停|维持现状|先不|仅文档|只做骨架/i;
13
- const HIGH_VALUE = /完整|核心|全量|推荐|生产可用|全平台|优先/i;
13
+ const HIGH_VALUE = /完整|核心|全量|生产可用|全平台|优先/i;
14
+ const NEGATED_RECOMMENDATION = /不\s*(?:推荐|建议)|\bnot\s+recommended\b/i;
14
15
 
15
16
  function clean(value) {
16
17
  return typeof value === 'string' ? value.trim() : '';
17
18
  }
18
19
 
19
- /** 选项开头的字母编号(`B.` / `B、` / `B)` / `B:`)。 */
20
+ /** 识别字母编号,也接受 `A(推荐):…` 或 `B 核心方案`。 */
20
21
  function optionLetter(value) {
21
- const match = /^\s*[((]?([A-Za-z])[))..、::]/.exec(value);
22
+ const match = /^\s*[((]?([A-Za-z])(?:[((][^))]+[))]\s*[..、::]|[))..、::]|\s+)/.exec(value);
22
23
  return match === null ? null : match[1].toUpperCase();
23
24
  }
24
25
 
@@ -32,6 +33,9 @@ function recommendationLetter(recommendation) {
32
33
  /** 显式建议命中哪个选项:字母编号优先,其次双向包含。 */
33
34
  function explicitPick(options, recommendation) {
34
35
  if (recommendation === '') return null;
36
+ const exact = options.find((option) => option === recommendation);
37
+ if (exact !== undefined) return exact;
38
+ if (NEGATED_RECOMMENDATION.test(recommendation)) return null;
35
39
  const letter = recommendationLetter(recommendation);
36
40
  if (letter !== null) {
37
41
  const byLetter = options.find((option) => optionLetter(option) === letter);
@@ -40,18 +44,14 @@ function explicitPick(options, recommendation) {
40
44
  return options.find((option) => recommendation.includes(option) || option.includes(recommendation)) ?? null;
41
45
  }
42
46
 
43
- function scoreOption(option, question) {
44
- const value = clean(option);
45
- if (value === '') return -100;
47
+ function scoreOption(value) {
48
+ // 否定说明优先于正向关键词;不把选项编号当作交付价值。
49
+ if (NEGATED_RECOMMENDATION.test(value)) return -100;
46
50
  let score = 0;
47
- if (/推荐/i.test(value)) score += 20;
51
+ if (/推荐|\brecommended\b/i.test(value)) score += 20;
48
52
  if (HIGH_VALUE.test(value)) score += 12;
49
- if (/B\b|C\b|核心|完整/i.test(value)) score += 6;
53
+ if (/核心|完整/i.test(value)) score += 6;
50
54
  if (LOW_VALUE.test(value)) score -= 20;
51
- if (/A\b|最小/i.test(value)) score -= 8;
52
- const recommendation = clean(question?.recommendation);
53
- if (recommendation !== '' && recommendation.includes(value)) score += 30;
54
- if (recommendation !== '' && value.includes(recommendation)) score += 20;
55
55
  return score;
56
56
  }
57
57
 
@@ -68,7 +68,7 @@ export function chooseDecisionAnswers(questions) {
68
68
  const explicit = explicitPick(options, recommendation);
69
69
  if (explicit !== null) return { id, value: explicit };
70
70
  const picked = options
71
- .map((option) => ({ option, score: scoreOption(option, question) }))
71
+ .map((option) => ({ option, score: scoreOption(option) }))
72
72
  .sort((left, right) => right.score - left.score)[0];
73
73
  return { id, value: picked?.option || recommendation || '按完整核心方案执行' };
74
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.144",
3
+ "version": "0.4.146",
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",