@suifei/dsh-ai-team 0.4.159 → 0.4.160

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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.160 - 2026-12-04
4
+
5
+ - DSH 会话建队可按目标里明确出现的分工补齐预设,并把补位依据放入同一份建队草稿。确认时重新核对名单。初始化中断后可按确认时的名单补齐。感谢 @buger-gif 提供按目标增补岗位的场景(#121)。
6
+
3
7
  ## 0.4.159 - 2026-12-04
4
8
 
5
9
  - 在 DSH 会话建队目标末尾可用「配 6 个人」指定人数。草稿显示目标人数、预设人数和岗位,人数不一致时先提示调整预设。感谢 @buger-gif 的会话组队与指定人数反馈(#121)。
package/README.md CHANGED
@@ -37,6 +37,7 @@
37
37
 
38
38
  ## 最近更新
39
39
 
40
+ - **会话建队按目标补位**(0.4.160)。当目标明确需要的岗位能补齐预设空缺时,同一草稿会列出新增岗位和匹配依据。确认时重新核对整份编制。感谢 [@buger-gif](https://github.com/buger-gif),[#121](https://github.com/suifei/dsh-ai-team/issues/121)。
40
41
  - **会话建队人数核对**(0.4.159)。目标可用「配 6 个人」指定人数,草稿列出目标人数和预设编制,人数不一致时先提示调整预设。感谢 [@buger-gif](https://github.com/buger-gif),[#121](https://github.com/suifei/dsh-ai-team/issues/121)。
41
42
  - **实时代理树槽位**(0.4.158)。支持 `capacityOf` 的宿主会在编制巡检中报告已占用和剩余槽位,建议新增成员时可看出同时启动是否需要排队。感谢 [@buger-gif](https://github.com/buger-gif),[#116](https://github.com/suifei/dsh-ai-team/issues/116)。
42
43
  - **DSH 0.2.3 Alpha 看板兼容**(0.4.158)。工作台沿用宿主 Web 路由的会话认证,修复已登录时看板仍加载失败的问题。感谢 [@Estelle00](https://github.com/Estelle00),[#122](https://github.com/suifei/dsh-ai-team/issues/122)。
@@ -144,7 +145,7 @@ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asi
144
145
 
145
146
  可用 `/ai-team 建队 --recommend 整理接口文档` 根据目标匹配文档、内容、教育、视频或游戏预设。唯一候选会随匹配依据进入草稿。有多个候选或线索不足时,用 `--team` 指定预设。省略这两个选项时使用设置中的团队。
146
147
 
147
- 若有明确人数,可用 `/ai-team 建队 --recommend 编写培训教材,配 6 个人`。预设需要达到目标人数才能生成草稿。人数不一致时,可以用 `--team` 选择其他预设或在文渊阁调整预设。
148
+ 若有明确人数,可用 `/ai-team 建队 --recommend 编写培训教材,配 6 个人`。也可以在目标中说明缺少的分工,例如 `/ai-team 建队 --recommend 整理接口文档,做交互体验评审,配六人`。这个例子在文档预设基础上补入 UX 设计,草稿会标出「体验、交互」作为依据。候选人数或分工有歧义时,先明确目标中的分工,或用 `--team` 指定人数匹配的预设。
148
149
 
149
150
  会话会显示工作目录、目标、团队预设、人数与岗位。输入草稿末尾的 `/ai-team 确认 草稿ID` 创建项目,或用对应的取消命令丢弃草稿。草稿跟随当前会话,宿主重启后可以重新生成。
150
151
 
@@ -433,7 +434,7 @@ round-19 DeepSeek + Zhipu 双 provider
433
434
  | 贡献者 | 贡献 | 带来的进展 |
434
435
  |---|---|---|
435
436
  | [@idontlikefruit](https://github.com/idontlikefruit) | 受阻状态的三组复现输入 [#115](https://github.com/suifei/dsh-ai-team/issues/115) | 统一看板徽标、读屏和分组统计的受阻判定,保留历史依赖 |
436
- | [@buger-gif](https://github.com/buger-gif) | 编制巡检、离队交接案例 [#116](https://github.com/suifei/dsh-ai-team/issues/116)、[#117](https://github.com/suifei/dsh-ai-team/issues/117),派发空转记录 [#120](https://github.com/suifei/dsh-ai-team/issues/120),会话建队、指定人数与调整编制场景 [#121](https://github.com/suifei/dsh-ai-team/issues/121) | 统一认领与离队顺序,减少派发空转,记录验收缺口与代理树的实时槽位。在 DSH 会话按目标建议预设并核对人数,确认一句话编制草稿及原任务交接 |
437
+ | [@buger-gif](https://github.com/buger-gif) | 编制巡检、离队交接案例 [#116](https://github.com/suifei/dsh-ai-team/issues/116)、[#117](https://github.com/suifei/dsh-ai-team/issues/117),派发空转记录 [#120](https://github.com/suifei/dsh-ai-team/issues/120),会话建队、指定人数、按目标补位与调整编制场景 [#121](https://github.com/suifei/dsh-ai-team/issues/121) | 统一认领与离队顺序,减少派发空转,记录验收缺口与代理树的实时槽位。在 DSH 会话按目标建议预设、核对人数和补位依据,确认建队及原任务交接 |
437
438
  | [@Estelle00](https://github.com/Estelle00) | DSH 0.2.3 启动 503 的复现和桌面验证 [#122](https://github.com/suifei/dsh-ai-team/issues/122) | 接入新版会话鉴权接口,恢复工作台初始化,并在 Alpha 宿主验证看板登录 |
438
439
  | [@phm101299-ui](https://github.com/phm101299-ui) | PMO 冷恢复的复现、根因和桌面验证 [#112](https://github.com/suifei/dsh-ai-team/issues/112) | 让原 PMO 在宿主重启后带着模型路由继续工作,保留成员关系和任务 |
439
440
  | [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) | 成员与自定义人才可在文渊阁选择已安装的技能或导入完整技能包。0.4.151 统一新建人才的导入入口,并由文渊阁直接安装整包 |
package/index.js CHANGED
@@ -82,7 +82,7 @@ import { readAttachment, uploadAttachment } from './lib/host/attachment-routes.j
82
82
  import { createDiagLogger, defaultDiagDir, installDiagSink } from './lib/diaglog.js';
83
83
  import { CATALOG_PACKAGE, clearOfficialCatalog, officialStatus, syncOfficialCatalog } from './lib/domain/catalog-sync.js';
84
84
  import { AVATAR_PACKAGE, avatarFile, avatarOptions, renderAvatarSvg, startAvatarLib } from './lib/domain/avatar.js';
85
- import { DEFAULT_TEAM, catalogRoots, deleteTalent, deleteTeam, forkTalent, installSkill, listInstallableSkills, listTalents, listTeams, loadCatalog, matchTeamPresets, readSkillText, resolveTeam, talentFromMember, talentIdFrom, uniqueTalentId, uniqueTeamId, userCatalogDir, writeTalent, writeTeam } from './lib/domain/catalog.js';
85
+ import { DEFAULT_TEAM, catalogRoots, deleteTalent, deleteTeam, forkTalent, installSkill, listInstallableSkills, listTalents, listTeams, loadCatalog, matchTeamPresets, readSkillText, resolveTeam, suggestTeamSupplements, talentFromMember, talentIdFrom, uniqueTalentId, uniqueTeamId, userCatalogDir, writeTalent, writeTeam } from './lib/domain/catalog.js';
86
86
 
87
87
  export const name = 'ai-team';
88
88
 
@@ -2545,6 +2545,7 @@ export function apply(ctx, config = {}) {
2545
2545
  if (disposed || booted === null) throw new Error('team ledger is unavailable');
2546
2546
  let next = projectRuntime(nextProjectId);
2547
2547
  if (next === null) {
2548
+ const resumeInitialRoster = !booted.registry.list().some(({ id }) => id === nextProjectId);
2548
2549
  next = await ProjectRuntime.open({
2549
2550
  rootDir: booted.dataDir,
2550
2551
  projectId: nextProjectId,
@@ -2554,6 +2555,7 @@ export function apply(ctx, config = {}) {
2554
2555
  diag,
2555
2556
  pmoMaxRounds: config.pmoMaxRounds,
2556
2557
  teamPreset: blueprint ? null : teamPreset ?? teamPresetFor(config, diag),
2558
+ resumeInitialRoster,
2557
2559
  blueprint,
2558
2560
  pmoAuto,
2559
2561
  });
@@ -2591,17 +2593,30 @@ export function apply(ctx, config = {}) {
2591
2593
  const nativeTeamCommand = sessionTeamCommand({
2592
2594
  prepare(input) {
2593
2595
  const project = projectInput(input);
2594
- if (!input.recommend) return { ...project, teamPreset: teamPresetFor(config, diag, input.team) };
2595
2596
  const catalog = talentCatalog(diag);
2596
- const candidates = matchTeamPresets(catalog, project.goal);
2597
- diag.append({ ev: 'session.team.recommendation', candidates: candidates.map(({ id, terms }) => ({ id, terms })) });
2598
- if (candidates.length !== 1) {
2599
- const hint = '请用 /ai-team 建队 --team 预设ID 目标 指定团队。';
2600
- const summary = candidates.map(({ name, id, terms }) => `- ${name}(${id}) · ${terms.join('、')}`).join('\n');
2601
- fail(ERRORS.INVALID_ARGUMENT, summary ? `目标对应多个团队。${hint}\n${summary}` : `目标中缺少明确的团队线索。${hint}`);
2597
+ let chosenTeam = input.team;
2598
+ let matchedTerms;
2599
+ if (input.recommend) {
2600
+ const candidates = matchTeamPresets(catalog, project.goal);
2601
+ diag.append({ ev: 'session.team.recommendation', candidates: candidates.map(({ id, terms }) => ({ id, terms })) });
2602
+ if (candidates.length !== 1) {
2603
+ const hint = '请用 /ai-team 建队 --team 预设ID 目标 指定团队。';
2604
+ const summary = candidates.map(({ name, id, terms }) => `- ${name}(${id}) · ${terms.join('、')}`).join('\n');
2605
+ fail(ERRORS.INVALID_ARGUMENT, summary ? `目标对应多个团队。${hint}\n${summary}` : `目标中缺少明确的团队线索。${hint}`);
2606
+ }
2607
+ chosenTeam = candidates[0].id;
2608
+ matchedTerms = candidates[0].terms;
2609
+ }
2610
+ const teamPreset = teamPresetFor(config, diag, chosenTeam, catalog);
2611
+ const { preset, suggestions, added } = suggestTeamSupplements(catalog, teamPreset, project.goal, input.requestedMembers);
2612
+ if (suggestions.length > 0) {
2613
+ diag.append({
2614
+ ev: 'session.team.supplements', preset: teamPreset.id, requestedMembers: input.requestedMembers,
2615
+ candidates: suggestions.map(({ id, terms }) => ({ id, terms })),
2616
+ added: added.map(({ member }) => member.talent.id),
2617
+ });
2602
2618
  }
2603
- const [match] = candidates;
2604
- return { ...project, teamPreset: teamPresetFor(config, diag, match.id, catalog), matchedTerms: match.terms };
2619
+ return { ...project, teamPreset: preset, matchedTerms, suggestions, supplements: added };
2605
2620
  },
2606
2621
  create: async (id, input) => (await activateProject(id, { ...input, pmoAuto: false })).service.state.projects[id],
2607
2622
  prepareRoster: createSessionRoster({
@@ -203,6 +203,20 @@ export function listTalents(catalog) {
203
203
  .sort((a, b) => a.category.localeCompare(b.category, 'zh') || a.name.localeCompare(b.name, 'zh'));
204
204
  }
205
205
 
206
+ function resolvedTeamMember(talent, member) {
207
+ return {
208
+ id: member.id,
209
+ name: member.name || talent.name,
210
+ role: member.role || talent.role,
211
+ duty: member.duty ?? talent.duty,
212
+ personality: member.personality || talent.personality,
213
+ skills: [...new Set([...talent.skills, ...(member.skills ?? [])])],
214
+ talent: { id: talent.id, version: talent.version, source: talent.source },
215
+ model: talent.model,
216
+ avatar: talent.avatar ?? null,
217
+ };
218
+ }
219
+
206
220
  /**
207
221
  * 团队 → 可直接建成员的名单:每位成员按引用的人才补齐名字、岗位、职责、性格与技能
208
222
  * (团队里写了的覆盖人才的)。团队缺失、写坏或引用了不存在的人才时退回默认团队并记 `.fail`。
@@ -217,17 +231,7 @@ export function resolveTeam(catalog, name = DEFAULT_TEAM, { diag } = {}) {
217
231
  const members = entry.members.map((member) => {
218
232
  const talent = catalog.talents.get(member.talent);
219
233
  if (talent === undefined) throw new Error(`team ${wanted}: talent ${member.talent} not found`);
220
- return {
221
- id: member.id,
222
- name: member.name || talent.name,
223
- role: member.role || talent.role,
224
- duty: member.duty ?? talent.duty,
225
- personality: member.personality || talent.personality,
226
- skills: [...new Set([...talent.skills, ...member.skills])],
227
- talent: { id: talent.id, version: talent.version, source: talent.source },
228
- model: talent.model,
229
- avatar: talent.avatar ?? null,
230
- };
234
+ return resolvedTeamMember(talent, member);
231
235
  });
232
236
  return { id: wanted, source: entry.source, dir: entry.dir, team: { name: entry.name || wanted, description: entry.description, lead: entry.lead, procedures: entry.procedures, members } };
233
237
  } catch (error) {
@@ -379,23 +383,82 @@ const PRESET_GOAL_TERMS = {
379
383
  game: ['小游戏', '游戏开发', '游戏原型', '游戏玩法', 'game prototype'],
380
384
  };
381
385
 
386
+ const goalTerm = (term) => term.normalize('NFKC').toLowerCase().trim();
387
+
388
+ function goalClauses(goal) {
389
+ return goalTerm(goal).split(/[,。;、!?,;!?\r\n]+/u)
390
+ .filter((clause) => !/(?:不要|不用|无需|不需要|不做|别|排除|\b(?:not|no|without|exclude)\b)/u.test(clause));
391
+ }
392
+
393
+ function matchingGoalTerms(clauses, terms) {
394
+ return terms.filter((value) => {
395
+ const term = goalTerm(value);
396
+ if (term === '') return false;
397
+ if (/^[a-z\d][a-z\d -]*$/u.test(term)) {
398
+ const word = new RegExp(`\\b${term}\\b`, 'u');
399
+ return clauses.some((clause) => word.test(clause));
400
+ }
401
+ return clauses.some((clause) => clause.includes(term));
402
+ });
403
+ }
404
+
405
+ const recommendableTeams = (catalog) => listTeams(catalog).filter((team) =>
406
+ Object.hasOwn(PRESET_GOAL_TERMS, team.id) && !team.broken && team.source !== 'user');
407
+
382
408
  /** 只按现有预设的交付物找候选。命中多种方向时保留候选,交给用户选。 */
383
409
  export function matchTeamPresets(catalog, goal) {
384
- const clauses = goal.normalize('NFKC').toLowerCase().split(/[,。;、!?,;!?\r\n]+/u)
385
- .filter((clause) => !/(?:不要|不用|无需|不需要|不做|别|排除|\b(?:not|no|without|exclude)\b)/u.test(clause));
386
- const candidates = [];
387
- for (const team of listTeams(catalog)) {
388
- if (!Object.hasOwn(PRESET_GOAL_TERMS, team.id) || team.broken || team.source === 'user') continue;
389
- const terms = PRESET_GOAL_TERMS[team.id].filter((term) => {
390
- if (/^[a-z ]+$/u.test(term)) {
391
- const word = new RegExp(`\\b${term}\\b`, 'u');
392
- return clauses.some((clause) => word.test(clause));
393
- }
394
- return clauses.some((clause) => clause.includes(term));
395
- });
396
- if (terms.length > 0) candidates.push({ id: team.id, name: team.name, terms });
410
+ const clauses = goalClauses(goal);
411
+ return recommendableTeams(catalog).flatMap(({ id, name }) => {
412
+ const terms = matchingGoalTerms(clauses, PRESET_GOAL_TERMS[id]);
413
+ return terms.length > 0 ? [{ id, name, terms }] : [];
414
+ });
415
+ }
416
+
417
+ function claimMemberId(talent, used) {
418
+ const base = `mem_${talent.replace(/-/g, '_')}`.slice(0, 60);
419
+ let id = base;
420
+ for (let n = 2; used.has(id); n += 1) id = `${base.slice(0, 56)}_${n}`;
421
+ used.add(id);
422
+ return id;
423
+ }
424
+
425
+ /** 只用已支持推荐的预设和人才库中明确命中的岗位或标签,补齐目标需要的空缺。 */
426
+ export function suggestTeamSupplements(catalog, preset, goal, requestedMembers) {
427
+ const members = preset.team.members;
428
+ const empty = { preset, suggestions: [], added: [] };
429
+ if (!Number.isSafeInteger(requestedMembers) || requestedMembers <= members.length || preset.source === 'user') return empty;
430
+ const gap = requestedMembers - members.length;
431
+ const teams = recommendableTeams(catalog);
432
+ if (!teams.some(({ id }) => id === preset.id)) return empty;
433
+
434
+ const talentIds = new Set(members.map(({ talent }) => talent.id));
435
+ const coveredTerms = new Set(members.flatMap(({ role, talent }) =>
436
+ [role, ...(catalog.talents.get(talent.id)?.tags ?? [])]).map(goalTerm));
437
+ const pool = new Set(teams.flatMap(({ members: teamMembers }) => teamMembers.map(({ talent }) => talent)));
438
+ const clauses = goalClauses(goal);
439
+ const suggestions = [];
440
+ const termCounts = new Map();
441
+ for (const id of pool) {
442
+ const talent = catalog.talents.get(id);
443
+ if (talentIds.has(id) || talent.source === 'user' || talent.duty === 'lead') continue;
444
+ const terms = matchingGoalTerms(clauses, [talent.role, ...talent.tags]);
445
+ const uncovered = [...new Map(terms.map((term) => [goalTerm(term), term]))]
446
+ .filter(([term]) => !coveredTerms.has(term));
447
+ if (uncovered.length === 0) continue;
448
+ for (const [term] of uncovered) termCounts.set(term, (termCounts.get(term) ?? 0) + 1);
449
+ suggestions.push({ id, name: talent.name, role: talent.role, terms: uncovered.map(([, term]) => term) });
450
+ }
451
+ const hasSharedOnlyEvidence = suggestions.some(({ terms }) =>
452
+ terms.every((term) => termCounts.get(goalTerm(term)) !== 1));
453
+ if (suggestions.length !== gap || hasSharedOnlyEvidence) {
454
+ return { ...empty, suggestions };
397
455
  }
398
- return candidates;
456
+ const used = new Set(members.map(({ id }) => id));
457
+ const added = suggestions.map(({ id, terms }) => ({
458
+ member: resolvedTeamMember(catalog.talents.get(id), { id: claimMemberId(id, used) }),
459
+ terms,
460
+ }));
461
+ return { preset: { ...preset, team: { ...preset.team, members: [...members, ...added.map(({ member }) => member)] } }, suggestions, added };
399
462
  }
400
463
 
401
464
  /**
@@ -414,10 +477,7 @@ export function writeTeam(userRoot, id, input, catalog) {
414
477
  const members = raw.map((m, i) => {
415
478
  const talent = text(m?.talent, 64);
416
479
  if (!SLUG.test(talent) || (catalog && !catalog.talents.has(talent))) throw new Error(`第 ${i + 1} 位成员引用的人才不存在:${String(m?.talent)}`);
417
- const base = `mem_${talent.replace(/-/g, '_')}`.slice(0, 60);
418
- let memberId = base;
419
- for (let n = 2; used.has(memberId); n += 1) memberId = `${base.slice(0, 56)}_${n}`;
420
- used.add(memberId);
480
+ const memberId = claimMemberId(talent, used);
421
481
  const label = text(m?.name, 40);
422
482
  return { talent, id: memberId, ...(label ? { name: label } : {}) };
423
483
  });
@@ -3,8 +3,8 @@
3
3
  * UI placeholders: the Human can rename/re-role/re-model them, and the Lead is
4
4
  * the default Project owner so a one-line Main-stream request can start work.
5
5
  *
6
- * Seeded only when a Project has no Agent member yet. Once a member exists the
7
- * user's roster is authoritative and boot never adds these people back.
6
+ * Seeded for a new Project before it is registered. On later boots the
7
+ * user's roster is authoritative.
8
8
  *
9
9
  * The roster itself is configuration: a team under `teams/` that picks talents from
10
10
  * `talents/`, or a user team selected by the `teamPreset` setting (lib/domain/catalog.js).
@@ -61,7 +61,7 @@ async function upgradeLegacyDefaultNames(service, projectId, humanId, roster) {
61
61
  * roles and the user's own roster are never touched or duplicated.
62
62
  * @returns {Promise<{seeded: boolean, members: string[], renamed: string[]}>}
63
63
  */
64
- export async function seedDefaultRoster(service, projectId, { humanId = 'mem_human', preset = resolveTeam(loadCatalog()) } = {}) {
64
+ export async function seedDefaultRoster(service, projectId, { humanId = 'mem_human', preset = resolveTeam(loadCatalog()), resumeInitialRoster = false } = {}) {
65
65
  const blueprint = service.state.projects?.[projectId]?.blueprint;
66
66
  if (blueprint) {
67
67
  const actor = { kind: 'human', memberId: humanId };
@@ -81,7 +81,8 @@ export async function seedDefaultRoster(service, projectId, { humanId = 'mem_hum
81
81
  }
82
82
  const { team } = preset;
83
83
  const roster = team.members;
84
- if (agentMembers(service).length > 0) {
84
+ // 未登记的新项目可能在播种中途失败,按同一份确认名单补齐。
85
+ if (!resumeInitialRoster && agentMembers(service).length > 0) {
85
86
  const renamed = await upgradeLegacyDefaultNames(service, projectId, humanId, roster);
86
87
  // 补缺岗只是老项目补齐 UX/业务 的迁移:只按**内置默认团队**做,且只对本来就由默认团队组成的项目
87
88
  // (成员没记团队的老成员,或记的就是 default)。0.4.124 起内置团队不止一个(science、game…),
@@ -118,6 +119,7 @@ export async function seedDefaultRoster(service, projectId, { humanId = 'mem_hum
118
119
  }
119
120
  const added = [];
120
121
  for (const member of roster) {
122
+ if (resumeInitialRoster && service.state.members?.[member.id]?.kind === 'agent') continue;
121
123
  await service.dispatch({
122
124
  type: 'member.add',
123
125
  actor: { kind: 'human', memberId: humanId },
@@ -144,5 +146,5 @@ export async function seedDefaultRoster(service, projectId, { humanId = 'mem_hum
144
146
  payload: { ownerMemberId: team.lead, reason: 'seed default roster' },
145
147
  });
146
148
  }
147
- return { seeded: true, members: added, renamed: [] };
149
+ return { seeded: added.length > 0, members: added, renamed: [] };
148
150
  }
@@ -26,7 +26,7 @@ export class ProjectRuntime {
26
26
  this.service = service;
27
27
  }
28
28
 
29
- static async open({ rootDir, projectId = DEFAULT_PROJECT_ID, now = undefined, seed = true, projectName = '我的项目', projectGoal = '把事交给团队', workspacePath = '', diag = null, pmoMaxRounds = undefined, teamPreset = null, blueprint = null, pmoAuto = true }) {
29
+ static async open({ rootDir, projectId = DEFAULT_PROJECT_ID, now = undefined, seed = true, projectName = '我的项目', projectGoal = '把事交给团队', workspacePath = '', diag = null, pmoMaxRounds = undefined, teamPreset = null, resumeInitialRoster = false, blueprint = null, pmoAuto = true }) {
30
30
  const dir = join(rootDir, 'projects', projectId);
31
31
  mkdirSync(dir, { recursive: true });
32
32
  const ledger = openLedger({
@@ -91,7 +91,7 @@ export class ProjectRuntime {
91
91
  payload: { id: projectId, name: projectName, goal: projectGoal, workspacePath, seed: true, blueprint, pmoAuto },
92
92
  });
93
93
  }
94
- await seedDefaultRoster(service, projectId, { humanId: HUMAN_ID, ...(teamPreset ? { preset: teamPreset } : {}) });
94
+ await seedDefaultRoster(service, projectId, { humanId: HUMAN_ID, resumeInitialRoster, ...(teamPreset ? { preset: teamPreset } : {}) });
95
95
  await service.backfillHumanMentions(state.projects?.[projectId]?.workspacePath ?? '');
96
96
  } catch (error) {
97
97
  runtime.close();
@@ -15,7 +15,9 @@ function sessionWorkspace(session) {
15
15
  return realpathSync(requireWorkspaceDirectory(path));
16
16
  }
17
17
 
18
- const presetSignature = (preset) => JSON.stringify([preset.id, preset.source, preset.dir, preset.team]);
18
+ const draftSignature = ({ teamPreset, supplements }) => JSON.stringify([
19
+ teamPreset.id, teamPreset.source, teamPreset.dir, teamPreset.team, supplements,
20
+ ]);
19
21
 
20
22
  function requestedRosterSize(goal) {
21
23
  const count = /(?:^|[,;。\r\n])\s*配\s*([+-]?\d+(?:\.\d+)?|[零〇一二两三四五六七八九十]+)\s*(?:[个名位]\s*)?(?:人|成员)\s*[。.!]?$/u.exec(goal.normalize('NFKC'))?.[1];
@@ -66,21 +68,24 @@ export function sessionTeamCommand({ prepare, create, prepareRoster, diag }) {
66
68
  const recommend = /^--recommend(?:\s|$)/.test(argument);
67
69
  const goal = (recommend ? argument.slice('--recommend'.length) : selected?.[2] ?? argument).trim();
68
70
  if (goal === '' || (!selected && argument.startsWith('--team'))) return { kind: 'error', text: HELP };
69
- const input = { name: goal.split(/\r?\n/, 1)[0], goal, workspacePath, team: selected?.[1] ?? '', recommend };
70
71
  const requestedMembers = requestedRosterSize(goal);
72
+ const input = { name: goal.split(/\r?\n/, 1)[0], goal, workspacePath, team: selected?.[1] ?? '', recommend, requestedMembers };
71
73
  const prepareDraft = () => {
72
74
  const project = prepare(input);
73
75
  const count = project.teamPreset.team.members.length;
74
76
  if (requestedMembers !== null && count !== requestedMembers) {
75
77
  const { id, team } = project.teamPreset;
76
- fail(ERRORS.INVALID_ARGUMENT, `目标要求 ${requestedMembers} 人,${team.name}(${id})有 ${count} 人。请用 --team 选择匹配人数的预设,或在文渊阁调整预设后重新建队。`);
78
+ const suggestions = project.suggestions.map(({ role, name, terms }) => `- ${name} · ${role}(${terms.join('、')})`);
79
+ const hint = suggestions.length > 0 ? `\n匹配到这些补位候选,可在目标中明确所需分工。\n${suggestions.join('\n')}` : '';
80
+ fail(ERRORS.INVALID_ARGUMENT, `目标要求 ${requestedMembers} 人,${team.name}(${id})有 ${count} 人。请用 --team 选择匹配人数的预设,或在文渊阁调整预设后重新建队。${hint}`);
77
81
  }
78
82
  return project;
79
83
  };
80
84
  const proposed = prepareDraft();
81
85
  const members = proposed.teamPreset.team.members;
82
86
  const id = ids.project();
83
- const signature = presetSignature(proposed.teamPreset);
87
+ const signature = draftSignature(proposed);
88
+ const supplementEvidence = new Map(proposed.supplements.map(({ member, terms }) => [member.id, terms]));
84
89
  return preview(session, workspacePath, {
85
90
  id, action,
86
91
  details: { preset: proposed.teamPreset.id, members: members.length, requestedMembers },
@@ -91,7 +96,10 @@ export function sessionTeamCommand({ prepare, create, prepareRoster, diag }) {
91
96
  `预设 ${proposed.teamPreset.team.name}(${proposed.teamPreset.id})`,
92
97
  ...(proposed.matchedTerms ? [`匹配依据 ${proposed.matchedTerms.join('、')}`] : []),
93
98
  `编制 ${members.length} 人${requestedMembers !== null ? `(目标 ${requestedMembers} 人)` : ''}`,
94
- ...members.map((member) => `- ${member.name} · ${member.role}`),
99
+ ...members.map((member) => {
100
+ const terms = supplementEvidence.get(member.id);
101
+ return `- ${member.name} · ${member.role}${terms ? `(补位依据 ${terms.join('、')})` : ''}`;
102
+ }),
95
103
  '确认后创建项目,PMO 自动为关闭状态。',
96
104
  ],
97
105
  async apply() {
@@ -99,11 +107,11 @@ export function sessionTeamCommand({ prepare, create, prepareRoster, diag }) {
99
107
  try {
100
108
  approved = prepareDraft();
101
109
  } catch (error) {
102
- if (error instanceof DomainError) fail(ERRORS.REVISION, '团队预设已更新,请重新生成草稿后再确认。');
110
+ if (error instanceof DomainError) fail(ERRORS.REVISION, '团队预设或匹配证据已更新,请重新生成草稿后再确认。');
103
111
  throw error;
104
112
  }
105
- if (presetSignature(approved.teamPreset) !== signature) {
106
- fail(ERRORS.REVISION, '团队预设已更新,请重新生成草稿后再确认。');
113
+ if (draftSignature(approved) !== signature) {
114
+ fail(ERRORS.REVISION, '团队预设或匹配证据已更新,请重新生成草稿后再确认。');
107
115
  }
108
116
  const project = await create(id, approved);
109
117
  return `已创建「${project.name}」(${project.id})。可在文渊阁查看团队,准备好后开启 PMO 自动。`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.159",
3
+ "version": "0.4.160",
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",