dsh-collab-pair 1.1.0 → 1.2.1

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.
Files changed (4) hide show
  1. package/README.md +47 -5
  2. package/client.js +77 -6
  3. package/index.js +179 -52
  4. package/package.json +2 -2
package/README.md CHANGED
@@ -33,7 +33,9 @@ Manager receives a collaboration report → next round for that worker, or colla
33
33
  - Project manager: the workers it manages (state, round, current task, latest report, unlink) plus a form to link another worker.
34
34
  - Worker: its manager, current task, state, latest report, and a "Leave" action.
35
35
  - Not linked: the link form.
36
- 3. **All tasks** — a board across every collaboration. Each row shows the worker, its manager, round, **working state** (`Working` / `Waiting for report` / `Idle` / `Finished`), waiting time, current task, and latest report. Refresh re-reads it.
36
+ 3. **All tasks** — a board across every collaboration, grouped by **project**. Each row shows the worker, round, **working state** (`Working` / `Waiting for report` / `Idle` / `Finished`), waiting time, current task, and latest report. Refresh re-reads it.
37
+
38
+ The manager card also shows the **project name** and lets you rename it.
37
39
 
38
40
  The header also has a **Message language** selector (中文 / English). It switches the generated collaboration messages; the page labels follow the app language.
39
41
 
@@ -54,6 +56,24 @@ Once a round is dispatched, the worker finishing wakes the manager automatically
54
56
 
55
57
  Set `autoNudge: false` to disable reminders.
56
58
 
59
+ ## Projects
60
+
61
+ A project is the set of workers managed by one project-manager conversation. Different managers are different projects, so nothing mixes:
62
+
63
+ - On the first link the project name defaults to the manager conversation title (role prefix removed).
64
+ - Rename it in the manager card or with `collab_project({ name })` / `/collab project {"name":"…"}`; every worker of that manager follows the project.
65
+ - The board groups tasks by project (project name + manager).
66
+ - A worker belongs to exactly one project at a time; unlink it before linking it to another manager.
67
+
68
+ ## Link modes
69
+
70
+ Each worker is linked in one of two modes:
71
+
72
+ - **Temporary** (default): `collab_done` unbinds the pair automatically — the link record is removed, the title prefix is cleared, and the worker can join another manager.
73
+ - **Permanent**: `collab_done` ends the current project but keeps the association — the prefix and record stay, the board shows the worker as finished, and you can dispatch again later or remove it with `collab_unlink`.
74
+
75
+ Choose the mode in the link form, or pass `mode` to `collab_link`.
76
+
57
77
  ## Title prefixes
58
78
 
59
79
  Linking adds a prefix to both conversations and removes it when the link ends (or the last worker finishes):
@@ -84,12 +104,13 @@ For an existing conversation, call `collab_sessions` to get its id, then `collab
84
104
  | Tool | Role | Purpose |
85
105
  | --- | --- | --- |
86
106
  | `collab_sessions` | anyone | List recent conversations (id / title / activity / link state) |
87
- | `collab_link` | anyone | Link a worker; `role=worker` makes the current conversation the worker; `peer="new"` creates one |
107
+ | `collab_link` | anyone | Link a worker; `role=worker` makes the current conversation the worker; `peer="new"` creates one; `mode` picks temporary/permanent; `project` names the project |
88
108
  | `collab_dispatch` | manager | Dispatch one round; `worker` selects the worker (optional with a single worker), `acceptance` optional |
89
109
  | `collab_report` | worker | Report `summary` / `status`(done\|partial\|blocked) / `details` / `next` |
90
110
  | `collab_status` | anyone | A manager sees every worker's progress; a worker sees its manager and pending task |
91
111
  | `collab_configure` | manager | Set a worker's agent preset or model; without arguments it lists available presets |
92
- | `collab_done` | manager | Finish one worker (or `all=true`) |
112
+ | `collab_project` | manager | Set the project name shared by this manager's workers |
113
+ | `collab_done` | manager | Finish one worker (or `all=true`); temporary links unbind automatically |
93
114
  | `collab_unlink` | both | Remove a link; a manager uses `worker` or `all`, a worker leaves its own |
94
115
 
95
116
  ## `/collab` command
@@ -102,6 +123,7 @@ The settings page uses it; it can also be typed manually:
102
123
  /collab status
103
124
  /collab link {"peer":"new"}
104
125
  /collab link {"peer":"session-…"}
126
+ /collab project {"name":"…"}
105
127
  /collab configure {"worker":"session-…","preset":"ptc"}
106
128
  /collab configure {"worker":"session-…","provider":"deepseek-account","model":"deepseek-flash"}
107
129
  /collab dispatch {"worker":"session-…","task":"…","acceptance":"…"}
@@ -205,6 +227,24 @@ dsh plugin add dsh-collab-pair
205
227
 
206
228
  不需要提醒时设 `autoNudge: false`。
207
229
 
230
+ ## 项目
231
+
232
+ 一个项目就是「一个项目经理对话所管理的员工集合」。不同项目经理就是不同项目,互不混淆:
233
+
234
+ - 第一次关联时,项目名默认取项目经理对话的标题(去掉角色前缀)。
235
+ - 可在项目经理卡片里改名,或用 `collab_project({ name })` / `/collab project {"name":"…"}`;该经理的所有员工会一起归到新项目名。
236
+ - 看板按项目分组(项目名 + 项目经理)。
237
+ - 一个员工同一时间只属于一个项目;要换项目经理,先解除原关联。
238
+
239
+ ## 关联模式
240
+
241
+ 每个员工关联时选择一种模式:
242
+
243
+ - **临时**(默认):`collab_done` 后自动解绑——关联记录删除、标题前缀去掉,员工可以再加入其他项目经理。
244
+ - **永久**:`collab_done` 只结束当前项目,关联保留——前缀和记录都在,看板显示已结束,之后可以继续派发,直到手动 `collab_unlink`。
245
+
246
+ 在关联表单里选择,或给 `collab_link` 传 `mode`。
247
+
208
248
  ## 标题前缀
209
249
 
210
250
  关联时自动给两个对话加前缀,解除(或最后一个员工结束时)自动去掉:
@@ -231,12 +271,13 @@ dsh plugin add dsh-collab-pair
231
271
  | 工具 | 角色 | 作用 |
232
272
  | --- | --- | --- |
233
273
  | `collab_sessions` | 任何人 | 列出最近对话(id / 标题 / 活跃 / 是否已关联) |
234
- | `collab_link` | 任何人 | 关联员工;`role=worker` 表示当前对话成为对方的员工;`peer="new"` 新建员工 |
274
+ | `collab_link` | 任何人 | 关联员工;`role=worker` 表示当前对话成为对方的员工;`peer="new"` 新建;`mode` 选临时/永久;`project` 指定项目名 |
235
275
  | `collab_dispatch` | 项目经理 | 派发一轮;`worker` 指定员工(只有一个时可省略),`acceptance` 可选 |
236
276
  | `collab_report` | 员工 | 汇报 `summary` / `status`(done\|partial\|blocked) / `details` / `next` |
237
277
  | `collab_status` | 任何人 | 经理看所有员工进度;员工看自己的经理与待办 |
238
278
  | `collab_configure` | 项目经理 | 设置某个员工的 agent 预设或模型;不传参数时列出可用预设 |
239
- | `collab_done` | 项目经理 | 结束某个员工的协作;`all=true` 结束全部 |
279
+ | `collab_project` | 项目经理 | 设置该经理的员工所属的项目名 |
280
+ | `collab_done` | 项目经理 | 结束某个员工;临时关联会自动解绑;`all=true` 结束全部 |
240
281
  | `collab_unlink` | 双方 | 删除关联;经理用 `worker` 或 `all`,员工解除自己 |
241
282
 
242
283
  ## `/collab` 命令
@@ -249,6 +290,7 @@ dsh plugin add dsh-collab-pair
249
290
  /collab status
250
291
  /collab link {"peer":"new"}
251
292
  /collab link {"peer":"session-…"}
293
+ /collab project {"name":"…"}
252
294
  /collab configure {"worker":"session-…","preset":"ptc"}
253
295
  /collab configure {"worker":"session-…","provider":"deepseek-account","model":"deepseek-flash"}
254
296
  /collab dispatch {"worker":"session-…","task":"…","acceptance":"…"}
package/client.js CHANGED
@@ -28,6 +28,15 @@ window.__ModuleLoader__.load({
28
28
  peer: '员工对话',
29
29
  peerNew: '新建一个员工对话',
30
30
  link: '关联',
31
+ linkMode: '关联模式',
32
+ modeTemporary: '临时关联(完成即解绑)',
33
+ modePermanent: '永久关联(直到手动解除)',
34
+ modeTempShort: '临时',
35
+ modePermShort: '永久',
36
+ projectLabel: '项目',
37
+ projectUnnamed: '未命名项目',
38
+ projectSave: '保存项目名',
39
+ projectSaved: '项目名已更新',
31
40
  linkDone: '已关联员工。接下来在项目经理对话里派发任务。',
32
41
  workerPrefixHint: '关联后两个对话的标题会自动加上【项目经理】/【员工】前缀,解除时自动去掉。',
33
42
  managerTitle: '项目经理',
@@ -81,6 +90,15 @@ window.__ModuleLoader__.load({
81
90
  peer: 'Worker conversation',
82
91
  peerNew: 'Create a new worker conversation',
83
92
  link: 'Link',
93
+ linkMode: 'Link mode',
94
+ modeTemporary: 'Temporary (unbind when done)',
95
+ modePermanent: 'Permanent (until unlinked)',
96
+ modeTempShort: 'Temporary',
97
+ modePermShort: 'Permanent',
98
+ projectLabel: 'Project',
99
+ projectUnnamed: 'Unnamed project',
100
+ projectSave: 'Save project name',
101
+ projectSaved: 'Project name updated',
84
102
  linkDone: 'Worker linked. Dispatch tasks from the manager conversation.',
85
103
  workerPrefixHint: 'Linking adds a 【项目经理】/【员工】 prefix to both titles; unlinking removes it.',
86
104
  managerTitle: 'Project manager',
@@ -198,6 +216,8 @@ window.__ModuleLoader__.load({
198
216
  const [notice, setNotice] = React.useState(null)
199
217
  const [busy, setBusy] = React.useState(false)
200
218
  const [peer, setPeer] = React.useState('new')
219
+ const [mode, setMode] = React.useState('temporary')
220
+ const [projectDraft, setProjectDraft] = React.useState('')
201
221
  const commandsRef = React.useRef(commands)
202
222
  commandsRef.current = commands
203
223
 
@@ -291,7 +311,7 @@ window.__ModuleLoader__.load({
291
311
  }
292
312
 
293
313
  const linkWorker = () => {
294
- void act(`/collab link ${JSON.stringify({ peer })}`, t('linkDone'))
314
+ void act(`/collab link ${JSON.stringify({ peer, mode })}`, t('linkDone'))
295
315
  }
296
316
 
297
317
  const removeWorker = (worker) => {
@@ -304,12 +324,20 @@ window.__ModuleLoader__.load({
304
324
  void act(`/collab unlink ${JSON.stringify({})}`, t('removeDone'))
305
325
  }
306
326
 
327
+ const saveProject = () => {
328
+ const name = projectDraft.trim()
329
+ if (name === '') return
330
+ void act(`/collab project ${JSON.stringify({ name })}`, t('projectSaved')).then(() => setProjectDraft(''))
331
+ }
332
+
307
333
  const links = board !== null && Array.isArray(board.links) ? board.links : []
308
334
  const messageLang = board !== null && board.language === 'en' ? 'en' : 'zh'
335
+ const associated = links.filter((link) => link.status === 'active' || link.mode === 'permanent')
309
336
  const activeLinks = links.filter((link) => link.status === 'active')
310
- const managed = workId === undefined ? [] : activeLinks.filter((link) => link.manager === workId)
311
- const mine = workId === undefined ? undefined : activeLinks.find((link) => link.worker === workId)
337
+ const managed = workId === undefined ? [] : associated.filter((link) => link.manager === workId)
338
+ const mine = workId === undefined ? undefined : associated.find((link) => link.worker === workId)
312
339
  const role = managed.length > 0 ? 'manager' : mine === undefined ? null : 'worker'
340
+ const managerProject = managed.find((link) => typeof link.project === 'string' && link.project !== '')?.project ?? ''
313
341
  const peerChoices = sessions.filter((row) => row.id !== workId)
314
342
 
315
343
  const statusText = (value) => {
@@ -383,6 +411,7 @@ window.__ModuleLoader__.load({
383
411
  const reminderText = (link) => (link.nudges > 0
384
412
  ? ` · ${t('reminder', { count: link.nudges, max: board !== null && typeof board.maxNudges === 'number' ? board.maxNudges : 3 })}`
385
413
  : '')
414
+ const modeText = (link) => (link.mode === 'permanent' ? t('modePermShort') : t('modeTempShort'))
386
415
 
387
416
  const taskRow = (link) => {
388
417
  const state = stateOf(link)
@@ -391,7 +420,7 @@ window.__ModuleLoader__.load({
391
420
  h('div', { style: S.taskTitle }, link.workerTitle || link.worker),
392
421
  h('div', { style: S.mono }, link.worker),
393
422
  h('div', { style: S.muted },
394
- `${link.managerTitle || link.manager} · ${roundText(link)}${reminderText(link)}`,
423
+ `${link.managerTitle || link.manager} · ${roundText(link)}${reminderText(link)} · ${modeText(link)}`,
395
424
  ),
396
425
  link.pending === null || link.pending === undefined
397
426
  ? null
@@ -404,6 +433,19 @@ window.__ModuleLoader__.load({
404
433
  )
405
434
  }
406
435
 
436
+ const groups = []
437
+ const groupMap = new Map()
438
+ for (const link of links) {
439
+ const key = `${link.manager}\u0000${link.project || ''}`
440
+ let group = groupMap.get(key)
441
+ if (group === undefined) {
442
+ group = { key, manager: link.manager, managerTitle: link.managerTitle || link.manager, project: link.project || '', links: [] }
443
+ groupMap.set(key, group)
444
+ groups.push(group)
445
+ }
446
+ group.links.push(link)
447
+ }
448
+
407
449
  const boardCard = h('div', { style: S.card },
408
450
  h('div', { style: S.cardHead },
409
451
  h('h3', { style: S.cardTitle }, t('boardTitle')),
@@ -416,7 +458,13 @@ window.__ModuleLoader__.load({
416
458
  ? h('p', { style: S.intro }, busy ? t('loading') : t('noTasks'))
417
459
  : links.length === 0
418
460
  ? h('p', { style: S.intro }, t('noTasks'))
419
- : links.map(taskRow),
461
+ : groups.map((group) => h('div', { key: group.key, style: { display: 'flex', flexDirection: 'column', gap: 8 } },
462
+ h('div', { style: { display: 'flex', gap: 8, alignItems: 'baseline', flexWrap: 'wrap' } },
463
+ h('span', { style: { fontSize: 13, fontWeight: 600 } }, group.project || t('projectUnnamed')),
464
+ h('span', { style: S.muted }, `${t('managerTitle')}:${group.managerTitle}`),
465
+ ),
466
+ group.links.map(taskRow),
467
+ )),
420
468
  )
421
469
 
422
470
  const workerRow = (link) => {
@@ -425,7 +473,7 @@ window.__ModuleLoader__.load({
425
473
  h('div', { style: S.workerMain },
426
474
  h('div', { style: S.workerName }, link.workerTitle || link.worker),
427
475
  h('div', { style: S.mono }, link.worker),
428
- h('div', { style: S.muted }, `${roundText(link)}${reminderText(link)}`),
476
+ h('div', { style: S.muted }, `${roundText(link)}${reminderText(link)} · ${modeText(link)}`),
429
477
  link.pending === null || link.pending === undefined
430
478
  ? null
431
479
  : h('p', { style: S.taskText }, link.pending.task),
@@ -452,6 +500,16 @@ window.__ModuleLoader__.load({
452
500
  h('option', { value: 'new' }, t('peerNew')),
453
501
  peerChoices.map((row) => h('option', { key: row.id, value: row.id }, row.title))),
454
502
  ),
503
+ h('label', { style: S.label }, t('linkMode'),
504
+ h('select', {
505
+ style: S.input,
506
+ value: mode,
507
+ disabled: busy,
508
+ onChange: (event) => setMode(event.target.value),
509
+ },
510
+ h('option', { value: 'temporary' }, t('modeTemporary')),
511
+ h('option', { value: 'permanent' }, t('modePermanent'))),
512
+ ),
455
513
  h('div', { style: S.row },
456
514
  h('button', { type: 'button', style: S.primary, disabled: busy, onClick: linkWorker }, t('link')),
457
515
  ),
@@ -468,6 +526,19 @@ window.__ModuleLoader__.load({
468
526
  h('span', { style: S.badge }, t('managerTitle')),
469
527
  h('span', { style: S.muted }, `${t('managing')} ${managed.length} ${t('workerCount')}`),
470
528
  ),
529
+ h('div', { style: S.row },
530
+ h('span', { style: S.muted }, `${t('projectLabel')}:${managerProject || t('projectUnnamed')}`),
531
+ ),
532
+ h('div', { style: S.row },
533
+ h('input', {
534
+ style: { ...S.input, flex: 1 },
535
+ value: projectDraft,
536
+ placeholder: managerProject || t('projectUnnamed'),
537
+ disabled: busy,
538
+ onChange: (event) => setProjectDraft(event.target.value),
539
+ }),
540
+ h('button', { type: 'button', style: S.secondary, disabled: busy || projectDraft.trim() === '', onClick: saveProject }, t('projectSave')),
541
+ ),
471
542
  managed.length === 0 ? h('p', { style: S.intro }, t('noWorkers')) : managed.map(workerRow),
472
543
  ),
473
544
  linkForm,
package/index.js CHANGED
@@ -32,7 +32,7 @@ const DONE = 'done'
32
32
  const STOPPED = 'stopped'
33
33
  const REPORTS = new Set(['done', 'partial', 'blocked'])
34
34
  const PROMPT_TIMEOUT_MS = 180000
35
- const ENGINE = 'collab-pair/1.1.0'
35
+ const ENGINE = 'collab-pair/1.2.0'
36
36
 
37
37
  /** A recoverable failure whose message is meant for the model. */
38
38
  class CollabError extends Error {}
@@ -180,6 +180,7 @@ const LANGUAGES = {
180
180
  zh: {
181
181
  idle: '空闲',
182
182
  waiting: '等待回报',
183
+ finished: '已结束',
183
184
  statusLabel(status) {
184
185
  if (status === 'done') return '完成'
185
186
  if (status === 'partial') return '部分完成'
@@ -211,9 +212,10 @@ const LANGUAGES = {
211
212
  moreWorkers(count) {
212
213
  return `- …另有 ${count} 个员工,用 collab_status 查看`
213
214
  },
214
- managerSection({ count, rows, maxRounds }) {
215
+ managerSection({ count, rows, maxRounds, project }) {
215
216
  return [
216
217
  '## 双对话协作 · 你是项目经理',
218
+ ...(project ? [`项目:${project}`] : []),
217
219
  `你正在协调 ${count} 个员工对话;项目目标、任务拆解与验收标准由你在对话中掌握。`,
218
220
  '员工:',
219
221
  ...rows,
@@ -226,9 +228,10 @@ const LANGUAGES = {
226
228
  `- 每个员工最多 ${maxRounds} 轮。`,
227
229
  ].join('\n')
228
230
  },
229
- workerSection({ manager, round, pending }) {
231
+ workerSection({ manager, round, pending, project }) {
230
232
  return [
231
233
  '## 双对话协作 · 你是员工',
234
+ ...(project ? [`项目:${project}`] : []),
232
235
  `项目经理对话:${manager}`,
233
236
  `进度:第 ${round} 轮${pending ? ',待你完成本轮任务' : ''}`,
234
237
  '你负责执行项目经理派发的任务,并如实回报结果;项目目标与验收标准以派发消息为准,不要改变大方向或扩大范围。',
@@ -315,6 +318,7 @@ const LANGUAGES = {
315
318
  en: {
316
319
  idle: 'idle',
317
320
  waiting: 'waiting for report',
321
+ finished: 'finished',
318
322
  statusLabel(status) {
319
323
  if (status === 'done') return 'done'
320
324
  if (status === 'partial') return 'partially done'
@@ -346,9 +350,10 @@ const LANGUAGES = {
346
350
  moreWorkers(count) {
347
351
  return `- …and ${count} more workers; use collab_status to see all`
348
352
  },
349
- managerSection({ count, rows, maxRounds }) {
353
+ managerSection({ count, rows, maxRounds, project }) {
350
354
  return [
351
355
  '## Collaboration pair · You are the project manager',
356
+ ...(project ? [`Project: ${project}`] : []),
352
357
  `You coordinate ${count} worker conversations. You own the project goal, the task breakdown, and the acceptance criteria.`,
353
358
  'Workers:',
354
359
  ...rows,
@@ -361,9 +366,10 @@ const LANGUAGES = {
361
366
  `- At most ${maxRounds} rounds per worker.`,
362
367
  ].join('\n')
363
368
  },
364
- workerSection({ manager, round, pending }) {
369
+ workerSection({ manager, round, pending, project }) {
365
370
  return [
366
371
  '## Collaboration pair · You are a worker',
372
+ ...(project ? [`Project: ${project}`] : []),
367
373
  `Manager conversation: ${manager}`,
368
374
  `Progress: round ${round}${pending ? ', with a task waiting for you' : ''}`,
369
375
  'Execute the tasks the manager dispatches and report back honestly. The goal and acceptance criteria come from the dispatch message; do not change direction or expand the scope.',
@@ -491,6 +497,7 @@ export function apply(ctx, rawConfig) {
491
497
  })
492
498
  if (cfg.autoNudge) watchdogTimer = setInterval(() => { void runWatchdog() }, 60000)
493
499
  setTimeout(() => { void recoverPendingLinks() }, 5000)
500
+ setTimeout(() => { void backfillProjects() }, 3000)
494
501
 
495
502
  registerTools()
496
503
  registerCommand()
@@ -548,6 +555,8 @@ export function apply(ctx, rawConfig) {
548
555
  manager: value.manager,
549
556
  worker: value.worker,
550
557
  label: typeof value.label === 'string' ? value.label : '',
558
+ mode: value.mode === 'permanent' ? 'permanent' : 'temporary',
559
+ project: typeof value.project === 'string' ? value.project : '',
551
560
  goal: typeof value.goal === 'string' ? value.goal : '',
552
561
  status,
553
562
  round: Number.isSafeInteger(value.round) && value.round >= 0 ? value.round : 0,
@@ -611,21 +620,21 @@ export function apply(ctx, rawConfig) {
611
620
  function sectionText(context) {
612
621
  const agentId = context?.agent?.id ?? context?.scope?.id
613
622
  if (typeof agentId !== 'string') return ''
614
- const managed = managerLinks(agentId, true)
623
+ const managed = usableManagerLinks(agentId)
615
624
  if (managed.length > 0) {
616
625
  const rows = managed.slice(0, 8).map((link) => L.managerRow({
617
626
  label: link.label || (cfg.language === 'en' ? '(unnamed worker)' : '(未命名员工)'),
618
627
  worker: link.worker,
619
628
  round: link.round,
620
- state: link.pending === null ? L.idle : L.waiting,
629
+ state: link.status !== ACTIVE ? L.finished : link.pending === null ? L.idle : L.waiting,
621
630
  last: link.lastReport === null ? '' : L.statusLabel(link.lastReport.status),
622
631
  }))
623
632
  if (managed.length > 8) rows.push(L.moreWorkers(managed.length - 8))
624
- return L.managerSection({ count: managed.length, rows, maxRounds: cfg.maxRounds })
633
+ return L.managerSection({ count: managed.length, rows, maxRounds: cfg.maxRounds, project: managerProjectName(agentId) })
625
634
  }
626
- const link = workerLink(agentId)
635
+ const link = workerAssociation(agentId)
627
636
  if (link === undefined) return ''
628
- return L.workerSection({ manager: link.manager, round: link.round, pending: link.pending !== null })
637
+ return L.workerSection({ manager: link.manager, round: link.round, pending: link.pending !== null, project: link.project })
629
638
  }
630
639
 
631
640
  /** Render one dispatch message for a worker. */
@@ -836,6 +845,44 @@ export function apply(ctx, rawConfig) {
836
845
  return linkId === undefined ? undefined : links.get(linkId)
837
846
  }
838
847
 
848
+ /** The worker link a session still belongs to, including a finished permanent one. */
849
+ function workerAssociation(sessionId) {
850
+ const active = workerLink(sessionId)
851
+ if (active !== undefined) return active
852
+ for (const link of links.values()) {
853
+ if (link.worker === sessionId && link.mode === 'permanent') return link
854
+ }
855
+ return undefined
856
+ }
857
+
858
+ /** Links a manager can still act on: active ones plus permanent associations. */
859
+ function usableManagerLinks(managerId) {
860
+ return managerLinks(managerId).filter((link) => link.status === ACTIVE || link.mode === 'permanent')
861
+ }
862
+
863
+ /** Whether a manager still has a usable worker association. */
864
+ function managerHasWork(managerId) {
865
+ return usableManagerLinks(managerId).length > 0
866
+ }
867
+
868
+ /** The project name shared by one manager's links, or ''. */
869
+ function managerProjectName(managerId) {
870
+ for (const link of managerLinks(managerId)) {
871
+ if (typeof link.project === 'string' && link.project !== '') return link.project
872
+ }
873
+ return ''
874
+ }
875
+
876
+ /** Rename the project shared by every link of one manager. */
877
+ async function renameProject(managerId, name) {
878
+ for (const link of managerLinks(managerId)) {
879
+ if (link.project === name) continue
880
+ link.project = name
881
+ link.updatedAt = Date.now()
882
+ await persist(link)
883
+ }
884
+ }
885
+
839
886
  /** Index one link by its manager and (while active) its worker. */
840
887
  function index(link) {
841
888
  links.set(link.id, link)
@@ -928,20 +975,20 @@ export function apply(ctx, rawConfig) {
928
975
 
929
976
  /** Resolve one of a manager's active workers by id, link id, or label. */
930
977
  function resolveManagedLink(managerId, selector) {
931
- const active = managerLinks(managerId, true)
932
- if (active.length === 0) throw new CollabError('当前对话没有进行中的员工协作;先用 collab_link 关联一个员工。')
978
+ const candidates = usableManagerLinks(managerId)
979
+ if (candidates.length === 0) throw new CollabError('当前对话没有可用的员工协作;先用 collab_link 关联一个员工。')
933
980
  const text = typeof selector === 'string' ? selector.trim() : ''
934
981
  if (text === '') {
935
- if (active.length === 1) return active[0]
936
- throw new CollabError(`当前对话有 ${active.length} 个员工,请用 worker 参数指定:\n${workerList(active)}`)
982
+ if (candidates.length === 1) return candidates[0]
983
+ throw new CollabError(`当前对话有 ${candidates.length} 个员工,请用 worker 参数指定:\n${workerList(candidates)}`)
937
984
  }
938
- const exact = active.find((link) => link.worker === text || link.id === text)
985
+ const exact = candidates.find((link) => link.worker === text || link.id === text)
939
986
  if (exact !== undefined) return exact
940
987
  const needle = text.toLowerCase()
941
- const matches = active.filter((link) => typeof link.label === 'string' && link.label !== '' && link.label.toLowerCase().includes(needle))
988
+ const matches = candidates.filter((link) => typeof link.label === 'string' && link.label !== '' && link.label.toLowerCase().includes(needle))
942
989
  if (matches.length === 1) return matches[0]
943
990
  if (matches.length > 1) throw new CollabError(`"${text}" 匹配到多个员工,请用 sessionId 指定:\n${workerList(matches)}`)
944
- throw new CollabError(`没有找到员工 "${text}"。当前员工:\n${workerList(active)}`)
991
+ throw new CollabError(`没有找到员工 "${text}"。当前员工:\n${workerList(candidates)}`)
945
992
  }
946
993
 
947
994
  /** Global board: every link, active first, with the labels a human needs. */
@@ -968,6 +1015,8 @@ export function apply(ctx, rawConfig) {
968
1015
  worker: link.worker,
969
1016
  workerTitle: workerTitle ?? null,
970
1017
  status: link.status,
1018
+ mode: link.mode,
1019
+ project: link.project || '',
971
1020
  workerLive: workerAgent !== undefined,
972
1021
  workerRunning: workerAgent !== undefined && workerAgent.status === 'running',
973
1022
  managerRunning: managerAgent !== undefined && managerAgent.status === 'running',
@@ -1007,7 +1056,16 @@ export function apply(ctx, rawConfig) {
1007
1056
  }
1008
1057
 
1009
1058
  /** Send one round to the worker and record it as pending. */
1010
- async function dispatchRound(link, task, acceptance, signal, force) { if (link.status !== ACTIVE) throw new CollabError(`与该员工的协作已结束(${link.status}),不能继续派发。`)
1059
+ async function dispatchRound(link, task, acceptance, signal, force) {
1060
+ if (link.status !== ACTIVE) {
1061
+ if (link.mode === 'permanent' && link.status === DONE) {
1062
+ link.status = ACTIVE
1063
+ delete link.closedAt
1064
+ index(link)
1065
+ } else {
1066
+ throw new CollabError(`与该员工的协作已结束(${link.status}),不能继续派发。`)
1067
+ }
1068
+ }
1011
1069
  if (link.pending !== null && !force) {
1012
1070
  throw new CollabError(`第 ${link.pending.round} 轮仍在等待该员工回报,不要重复派发;需要覆盖请传 force=true。`)
1013
1071
  }
@@ -1177,6 +1235,24 @@ export function apply(ctx, rawConfig) {
1177
1235
  }
1178
1236
  }
1179
1237
 
1238
+ /**
1239
+ * Name links created before the project field existed: derive the project
1240
+ * from the manager conversation title once, then persist it.
1241
+ */
1242
+ async function backfillProjects() {
1243
+ if (!alive) return
1244
+ for (const link of [...links.values()]) {
1245
+ if (!alive) return
1246
+ if (typeof link.project === 'string' && link.project !== '') continue
1247
+ const title = await titleOf(link.manager)
1248
+ const name = typeof title === 'string' ? stripKnownPrefix(title) : ''
1249
+ if (name === '') continue
1250
+ link.project = name
1251
+ link.updatedAt = Date.now()
1252
+ await persist(link)
1253
+ }
1254
+ }
1255
+
1180
1256
  /** Serialize relays per link so one turn cannot relay twice. */
1181
1257
  function enqueueRelay(linkId, run) { const previous = relays.get(linkId) ?? Promise.resolve()
1182
1258
  const next = previous.then(run, run).catch((error) => {
@@ -1298,7 +1374,7 @@ export function apply(ctx, rawConfig) {
1298
1374
  .filter((row) => query === '' || (row.title ?? '').toLowerCase().includes(query) || row.sessionId.toLowerCase().includes(query))
1299
1375
  .slice(0, limit)
1300
1376
  .map((row) => {
1301
- const worker = workerLink(row.sessionId)
1377
+ const worker = workerAssociation(row.sessionId)
1302
1378
  const managed = managerLinks(row.sessionId, true)
1303
1379
  return {
1304
1380
  sessionId: row.sessionId,
@@ -1316,7 +1392,7 @@ export function apply(ctx, rawConfig) {
1316
1392
  ok: true,
1317
1393
  current: {
1318
1394
  sessionId: agent.id,
1319
- role: managerLinks(agent.id, true).length > 0 ? 'manager' : workerLink(agent.id) === undefined ? null : 'worker',
1395
+ role: managerHasWork(agent.id) ? 'manager' : workerAssociation(agent.id) === undefined ? null : 'worker',
1320
1396
  },
1321
1397
  sessions,
1322
1398
  note: sessions.length === 0
@@ -1329,12 +1405,14 @@ export function apply(ctx, rawConfig) {
1329
1405
  toolExecutors.link = register({
1330
1406
  name: 'collab_link',
1331
1407
  description:
1332
- '把当前对话与另一个对话关联:role=manager(默认)表示当前对话是项目经理、对方成为新的员工;一个项目经理可以关联多个员工。role=worker 表示当前对话成为对方的员工。peer 传 sessionId、标题关键词,或 "new"(新建一个员工对话)。',
1408
+ '把当前对话与另一个对话关联:role=manager(默认)表示当前对话是项目经理、对方成为新的员工;一个项目经理可以关联多个员工。role=worker 表示当前对话成为对方的员工。mode=temporary(默认,完成即解绑)或 permanent(一直关联直到人工解除)。peer 传 sessionId、标题关键词,或 "new"(新建一个员工对话)。',
1333
1409
  parameters: {
1334
1410
  type: 'object',
1335
1411
  properties: {
1336
1412
  peer: { type: 'string', description: 'sessionId、标题关键词,或 "new"。' },
1337
1413
  role: { type: 'string', enum: ['manager', 'worker'], description: '当前对话的角色,默认 manager。' },
1414
+ mode: { type: 'string', enum: ['temporary', 'permanent'], description: '关联模式:temporary 完成后自动解绑(默认),permanent 保留到人工解除。' },
1415
+ project: { type: 'string', description: '可选:项目名。同一个项目经理的员工会归到同一个项目,不同项目经理的项目彼此独立。' },
1338
1416
  goal: { type: 'string', description: '可选:项目总目标;不填时由项目经理在对话中掌握。' },
1339
1417
  task: { type: 'string', description: '可选:关联成功后立即派发给该员工的第一轮任务。' },
1340
1418
  acceptance: { type: 'string', description: '可选:第一轮任务的验收标准。' },
@@ -1346,14 +1424,18 @@ export function apply(ctx, rawConfig) {
1346
1424
  const agent = requireAgent(exec)
1347
1425
  const role = args?.role === 'worker' ? 'worker' : 'manager'
1348
1426
  const managed = managerLinks(agent.id, true)
1349
- const ownWorker = workerLink(agent.id)
1427
+ const ownWorker = workerAssociation(agent.id)
1428
+ if (workerLink(agent.id) !== undefined) {
1429
+ throw new CollabError(`当前对话已经是协作 ${ownWorker?.id ?? ''} 的员工,不能再加入其他协作;请先 collab_unlink。`)
1430
+ }
1350
1431
  if (ownWorker !== undefined) {
1351
- throw new CollabError(`当前对话已经是协作 ${ownWorker.id} 的员工,不能再加入其他协作;请先 collab_unlink。`)
1432
+ throw new CollabError(`当前对话已永久关联到协作 ${ownWorker.id}(已结束);请先 collab_unlink。`)
1352
1433
  }
1353
1434
  if (role === 'worker' && managed.length > 0) {
1354
1435
  throw new CollabError(`当前对话正在管理 ${managed.length} 个员工,不能同时作为别人的员工。`)
1355
1436
  }
1356
1437
  const goal = typeof args?.goal === 'string' ? args.goal.trim() : ''
1438
+ const requestedProject = typeof args?.project === 'string' ? args.project.trim() : ''
1357
1439
  let peerId
1358
1440
  let peerTitle
1359
1441
  const resolved = await resolvePeer(args?.peer, exec.signal)
@@ -1364,7 +1446,7 @@ export function apply(ctx, rawConfig) {
1364
1446
  peerTitle = resolved.title
1365
1447
  }
1366
1448
  if (peerId === agent.id) throw new CollabError('不能把对话与它自己关联。')
1367
- if (workerLink(peerId) !== undefined) {
1449
+ if (workerAssociation(peerId) !== undefined) {
1368
1450
  throw new CollabError(`目标对话 ${peerId} 已经是另一个协作的员工,请先解除那边的关联。`)
1369
1451
  }
1370
1452
  if (managerLinks(peerId, true).length > 0) {
@@ -1372,12 +1454,19 @@ export function apply(ctx, rawConfig) {
1372
1454
  }
1373
1455
  const manager = role === 'manager' ? agent.id : peerId
1374
1456
  const worker = role === 'manager' ? peerId : agent.id
1457
+ let project = requestedProject || managerProjectName(manager)
1458
+ if (project === '') {
1459
+ const managerTitle = await titleOf(manager)
1460
+ if (typeof managerTitle === 'string') project = stripKnownPrefix(managerTitle)
1461
+ }
1375
1462
  const link = {
1376
1463
  v: 1,
1377
1464
  id: `cp-${randomUUID().slice(0, 8)}`,
1378
1465
  manager,
1379
1466
  worker,
1380
1467
  label: role === 'manager' ? (typeof peerTitle === 'string' ? peerTitle : '') : '',
1468
+ mode: args?.mode === 'permanent' ? 'permanent' : 'temporary',
1469
+ project,
1381
1470
  goal,
1382
1471
  status: ACTIVE,
1383
1472
  round: 0,
@@ -1389,6 +1478,7 @@ export function apply(ctx, rawConfig) {
1389
1478
  }
1390
1479
  index(link)
1391
1480
  await persist(link)
1481
+ if (project !== '') await renameProject(manager, project)
1392
1482
  await applyPrefix(manager, cfg.prefixManager)
1393
1483
  await applyPrefix(worker, cfg.prefixWorker)
1394
1484
  let receipt = null
@@ -1410,6 +1500,7 @@ export function apply(ctx, rawConfig) {
1410
1500
  ok: true,
1411
1501
  linkId: link.id,
1412
1502
  role,
1503
+ mode: link.mode,
1413
1504
  manager,
1414
1505
  worker: { sessionId: worker, title: workerTitle ?? null },
1415
1506
  goal,
@@ -1417,8 +1508,8 @@ export function apply(ctx, rawConfig) {
1417
1508
  receipt,
1418
1509
  message: role === 'manager'
1419
1510
  ? (receipt === null
1420
- ? `已关联员工 ${worker}${managedNow > 1 ? `(当前共 ${managedNow} 个员工)` : ''}。用 collab_dispatch 派发任务。`
1421
- : `已关联员工 ${worker}${managedNow > 1 ? `(当前共 ${managedNow} 个员工)` : ''},第一轮任务已派发。`)
1511
+ ? `已关联员工 ${worker}${link.mode === 'permanent' ? '(永久关联)' : '(临时关联,完成即解绑)'}${managedNow > 1 ? `,当前共 ${managedNow} 个员工` : ''}。用 collab_dispatch 派发任务。`
1512
+ : `已关联员工 ${worker}${link.mode === 'permanent' ? '(永久关联)' : '(临时关联,完成即解绑)'}${managedNow > 1 ? `,当前共 ${managedNow} 个员工` : ''},第一轮任务已派发。`)
1422
1513
  : '协作已建立,你被设为员工角色;项目经理派发任务后会收到【协作任务】消息。',
1423
1514
  }
1424
1515
  },
@@ -1453,7 +1544,7 @@ export function apply(ctx, rawConfig) {
1453
1544
  message: `第 ${sent.round} 轮任务已派发给员工 ${link.worker}。该员工完成后,产出与反馈会自动作为用户消息回到本对话。`,
1454
1545
  }
1455
1546
  },
1456
- when: ({ agent }) => managerLinks(agent.id, true).length > 0,
1547
+ when: ({ agent }) => managerHasWork(agent.id),
1457
1548
  })
1458
1549
 
1459
1550
  toolExecutors.report = register({
@@ -1505,10 +1596,10 @@ export function apply(ctx, rawConfig) {
1505
1596
  async execute(_args, exec) {
1506
1597
  const agent = requireAgent(exec)
1507
1598
  const managed = managerLinks(agent.id)
1508
- const active = managed.filter((link) => link.status === ACTIVE)
1509
- if (active.length > 0) {
1599
+ const visible = managed.filter((link) => link.status === ACTIVE || link.mode === 'permanent')
1600
+ if (visible.length > 0) {
1510
1601
  const workers = []
1511
- for (const link of managed) {
1602
+ for (const link of visible) {
1512
1603
  const title = await titleOf(link.worker)
1513
1604
  if (title !== undefined && title !== link.label) link.label = title
1514
1605
  workers.push({
@@ -1516,6 +1607,8 @@ export function apply(ctx, rawConfig) {
1516
1607
  worker: link.worker,
1517
1608
  title: title ?? (link.label || null),
1518
1609
  status: link.status,
1610
+ mode: link.mode,
1611
+ project: link.project || null,
1519
1612
  round: link.round,
1520
1613
  pending: link.pending === null
1521
1614
  ? null
@@ -1549,14 +1642,15 @@ export function apply(ctx, rawConfig) {
1549
1642
  engine: ENGINE,
1550
1643
  language: cfg.language,
1551
1644
  role: 'manager',
1645
+ project: managerProjectName(agent.id) || null,
1552
1646
  manager: { sessionId: agent.id, title: (await titleOf(agent.id)) ?? null },
1553
1647
  maxRounds: cfg.maxRounds,
1554
- activeCount: active.length,
1648
+ activeCount: visible.filter((link) => link.status === ACTIVE).length,
1555
1649
  totalCount: managed.length,
1556
1650
  workers,
1557
1651
  }
1558
1652
  }
1559
- const link = workerLink(agent.id)
1653
+ const link = workerAssociation(agent.id)
1560
1654
  if (link === undefined) {
1561
1655
  return {
1562
1656
  linked: false,
@@ -1576,6 +1670,8 @@ export function apply(ctx, rawConfig) {
1576
1670
  language: cfg.language,
1577
1671
  linkId: link.id,
1578
1672
  role: 'worker',
1673
+ mode: link.mode,
1674
+ project: link.project || null,
1579
1675
  manager: { sessionId: link.manager, title: managerTitle ?? null },
1580
1676
  goal: link.goal || null,
1581
1677
  status: link.status,
@@ -1660,13 +1756,34 @@ export function apply(ctx, rawConfig) {
1660
1756
  message: '配置已应用;该员工下一轮会按新配置运行。',
1661
1757
  }
1662
1758
  },
1663
- when: ({ agent }) => managerLinks(agent.id, true).length > 0,
1759
+ when: ({ agent }) => managerHasWork(agent.id),
1760
+ })
1761
+
1762
+ toolExecutors.project = register({
1763
+ name: 'collab_project',
1764
+ description:
1765
+ '(仅项目经理)设置或修改当前项目名。项目名用于把该项目经理的员工归到同一个项目;不同项目经理的项目彼此独立。',
1766
+ parameters: {
1767
+ type: 'object',
1768
+ properties: { name: { type: 'string', description: '新的项目名,不能为空。' } },
1769
+ required: ['name'],
1770
+ },
1771
+ async execute(args, exec) {
1772
+ const agent = requireAgent(exec)
1773
+ const name = typeof args?.name === 'string' ? args.name.trim() : ''
1774
+ if (name === '') throw new CollabError('项目名不能为空。')
1775
+ const existing = managerLinks(agent.id)
1776
+ if (existing.length === 0) throw new CollabError('当前对话还没有关联员工;先 collab_link 再设置项目名。')
1777
+ await renameProject(agent.id, name)
1778
+ return { ok: true, project: name, workers: existing.length }
1779
+ },
1780
+ when: ({ agent }) => managerLinks(agent.id).length > 0,
1664
1781
  })
1665
1782
 
1666
1783
  toolExecutors.done = register({
1667
1784
  name: 'collab_done',
1668
1785
  description:
1669
- '(仅项目经理)宣布某个员工的项目完成:记录总结并结束与该员工的协作。有多个员工时用 worker 指定;all=true 结束全部员工。请在验收通过后调用。',
1786
+ '(仅项目经理)宣布某个员工的项目完成:记录总结并结束本轮协作。临时关联会同时自动解绑;永久关联保留到 collab_unlink。有多个员工时用 worker 指定;all=true 结束全部进行中的员工。请在验收通过后调用。',
1670
1787
  parameters: {
1671
1788
  type: 'object',
1672
1789
  properties: {
@@ -1693,8 +1810,10 @@ export function apply(ctx, rawConfig) {
1693
1810
  throw new CollabError(`当前对话有 ${active.length} 个员工,请用 worker 指定或传 all=true:\n${workerList(active)}`)
1694
1811
  }
1695
1812
  const closed = []
1813
+ const removed = []
1696
1814
  const notified = []
1697
1815
  for (const link of targets) {
1816
+ const temporary = link.mode !== 'permanent'
1698
1817
  link.status = DONE
1699
1818
  link.pending = null
1700
1819
  link.finalSummary = clip(summary, 4000)
@@ -1702,8 +1821,7 @@ export function apply(ctx, rawConfig) {
1702
1821
  link.updatedAt = Date.now()
1703
1822
  index(link)
1704
1823
  await persist(link)
1705
- await clearPrefix(link.worker)
1706
- closed.push({ linkId: link.id, worker: link.worker })
1824
+ closed.push({ linkId: link.id, worker: link.worker, mode: link.mode })
1707
1825
  if (cfg.notifyWorkerOnDone) {
1708
1826
  try {
1709
1827
  await deliver(link.worker, doneText(link, link.finalSummary), `cp-${link.id}-done-to-worker`, 'queue', AbortSignal.timeout(PROMPT_TIMEOUT_MS))
@@ -1712,16 +1830,24 @@ export function apply(ctx, rawConfig) {
1712
1830
  ctx.logger.warn(`collab-pair: notifying ${link.worker} of completion failed: ${String(error)}`)
1713
1831
  }
1714
1832
  }
1833
+ if (temporary) {
1834
+ await forget(link)
1835
+ await clearPrefix(link.worker)
1836
+ removed.push({ linkId: link.id, worker: link.worker })
1837
+ }
1715
1838
  }
1716
- if (managerLinks(agent.id, true).length === 0) await clearPrefix(agent.id)
1839
+ if (managerLinks(agent.id).length === 0) await clearPrefix(agent.id)
1717
1840
  return {
1718
1841
  ok: true,
1719
1842
  closed,
1843
+ removed,
1720
1844
  workerNotified: notified,
1721
- message: `已结束 ${closed.length} 个员工协作;历史记录仍保留在 collab_status 中。`,
1845
+ message: removed.length === 0
1846
+ ? `已结束 ${closed.length} 个员工协作(永久关联保留,可继续派发或手动解除)。`
1847
+ : `已结束 ${closed.length} 个员工协作,其中 ${removed.length} 个临时关联已自动解绑。`,
1722
1848
  }
1723
1849
  },
1724
- when: ({ agent }) => managerLinks(agent.id, true).length > 0,
1850
+ when: ({ agent }) => managerHasWork(agent.id),
1725
1851
  })
1726
1852
 
1727
1853
  toolExecutors.unlink = register({
@@ -1739,7 +1865,7 @@ export function apply(ctx, rawConfig) {
1739
1865
  },
1740
1866
  async execute(args, exec) {
1741
1867
  const agent = requireAgent(exec)
1742
- const ownWorker = workerLink(agent.id)
1868
+ const ownWorker = workerAssociation(agent.id)
1743
1869
  if (ownWorker !== undefined) {
1744
1870
  let notified = false
1745
1871
  if (args?.notify === true) {
@@ -1755,20 +1881,20 @@ export function apply(ctx, rawConfig) {
1755
1881
  const managerId = ownWorker.manager
1756
1882
  await forget(ownWorker)
1757
1883
  await clearPrefix(agent.id)
1758
- if (managerLinks(managerId, true).length === 0) await clearPrefix(managerId)
1884
+ if (managerLinks(managerId).length === 0) await clearPrefix(managerId)
1759
1885
  return { ok: true, removed: [{ linkId, worker: agent.id }], peerNotified: notified }
1760
1886
  }
1761
- const active = managerLinks(agent.id, true)
1762
- if (active.length === 0) throw new CollabError('当前对话没有进行中的员工协作,无需解除。')
1887
+ const candidates = usableManagerLinks(agent.id)
1888
+ if (candidates.length === 0) throw new CollabError('当前对话没有可解除的员工协作。')
1763
1889
  let targets
1764
1890
  if (args?.all === true) {
1765
- targets = active
1891
+ targets = candidates
1766
1892
  } else if (typeof args?.worker === 'string' && args.worker.trim() !== '') {
1767
1893
  targets = [resolveManagedLink(agent.id, args.worker)]
1768
- } else if (active.length === 1) {
1769
- targets = [active[0]]
1894
+ } else if (candidates.length === 1) {
1895
+ targets = [candidates[0]]
1770
1896
  } else {
1771
- throw new CollabError(`当前对话有 ${active.length} 个员工,请用 worker 指定或传 all=true:\n${workerList(active)}`)
1897
+ throw new CollabError(`当前对话有 ${candidates.length} 个员工,请用 worker 指定或传 all=true:\n${workerList(candidates)}`)
1772
1898
  }
1773
1899
  const removed = []
1774
1900
  let notified = 0
@@ -1786,10 +1912,10 @@ export function apply(ctx, rawConfig) {
1786
1912
  await forget(link)
1787
1913
  await clearPrefix(link.worker)
1788
1914
  }
1789
- if (managerLinks(agent.id, true).length === 0) await clearPrefix(agent.id)
1915
+ if (managerLinks(agent.id).length === 0) await clearPrefix(agent.id)
1790
1916
  return { ok: true, removed, peerNotified: notified > 0 }
1791
1917
  },
1792
- when: ({ agent }) => managerLinks(agent.id, true).length > 0 || workerLink(agent.id) !== undefined,
1918
+ when: ({ agent }) => managerHasWork(agent.id) || workerAssociation(agent.id) !== undefined,
1793
1919
  })
1794
1920
  }
1795
1921
 
@@ -1800,7 +1926,7 @@ export function apply(ctx, rawConfig) {
1800
1926
 
1801
1927
  /** Whether one session is an active worker. */
1802
1928
  function isWorker(sessionId) {
1803
- return workerLink(sessionId) !== undefined
1929
+ return workerAssociation(sessionId) !== undefined
1804
1930
  }
1805
1931
 
1806
1932
  /** Require the calling agent. */
@@ -1834,15 +1960,16 @@ export function apply(ctx, rawConfig) {
1834
1960
  link: 'link',
1835
1961
  dispatch: 'dispatch',
1836
1962
  configure: 'configure',
1963
+ project: 'project',
1837
1964
  done: 'done',
1838
1965
  unlink: 'unlink',
1839
1966
  sessions: 'sessions',
1840
1967
  }
1841
1968
  ctx.commands.register({
1842
1969
  name: 'collab',
1843
- description: '双对话协作:查看全部任务、关联员工、配置预设与语言、派发任务、收尾或解除。',
1970
+ description: '双对话协作:查看全部任务、关联员工、设置项目名、配置预设与语言、派发任务、收尾或解除。',
1844
1971
  input: {
1845
- hint: 'tasks | status | link --peer <id|new> | configure --preset <id> | language <zh|en> | dispatch --worker <id> --task ... | done --worker <id> --summary ... | unlink --worker <id>',
1972
+ hint: 'tasks | status | link --peer <id|new> | project --name <项目名> | configure --preset <id> | language <zh|en> | dispatch --worker <id> --task ... | done --worker <id> --summary ... | unlink --worker <id>',
1846
1973
  },
1847
1974
  handler: async (invocation) => {
1848
1975
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-collab-pair",
3
- "version": "1.1.0",
4
- "description": "For large projects: link one project-manager conversation with one or more worker conversations, dispatch each round from the manager instead of repeating prompts across conversations, relay results automatically, and keep unattended runs moving with a visual task board.",
3
+ "version": "1.2.1",
4
+ "description": "For large projects: link a project-manager conversation with one or more worker conversations (temporary links unbind when done, permanent links stay until unlinked), group managers and workers by project, dispatch each round from the manager instead of repeating prompts, relay results automatically, and keep unattended runs moving with a visual task board.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "keywords": [