teamsmith 0.1.2 → 0.3.0

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 (158) hide show
  1. package/README.md +13 -7
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +67 -0
  4. package/skills/teamsmith/SKILL.md +26 -8
  5. package/skills/teamsmith/extension/team-notify.ts +37 -6
  6. package/skills/teamsmith/extension/team.ts +438 -0
  7. package/skills/teamsmith/references/agent-adapters.md +7 -7
  8. package/skills/teamsmith/references/config.md +65 -18
  9. package/skills/teamsmith/references/migration.md +220 -34
  10. package/skills/teamsmith/references/protocol.md +250 -25
  11. package/skills/teamsmith/references/troubleshooting.md +124 -7
  12. package/skills/teamsmith/references/workflows.md +66 -20
  13. package/skills/teamsmith/scripts/lib/cmd-agents.sh +525 -90
  14. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +71 -10
  15. package/skills/teamsmith/scripts/lib/cmd-config.sh +562 -128
  16. package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
  17. package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
  18. package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
  19. package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
  20. package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
  21. package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
  22. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
  23. package/skills/teamsmith/scripts/lib/cmd-project.sh +149 -105
  24. package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
  25. package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
  26. package/skills/teamsmith/scripts/lib/cmd-review.sh +188 -40
  27. package/skills/teamsmith/scripts/lib/cmd-status.sh +268 -30
  28. package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
  29. package/skills/teamsmith/scripts/lib/cmd-watch.sh +634 -54
  30. package/skills/teamsmith/scripts/lib/common.sh +1560 -109
  31. package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
  32. package/skills/teamsmith/scripts/monitor.mjs +34 -3
  33. package/skills/teamsmith/scripts/panel/README.md +22 -11
  34. package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
  35. package/skills/teamsmith/scripts/panel/panel.js +226 -224
  36. package/skills/teamsmith/scripts/panel/src/App.tsx +478 -184
  37. package/skills/teamsmith/scripts/panel/src/clipboard.ts +11 -5
  38. package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
  39. package/skills/teamsmith/scripts/panel/src/data.ts +95 -7
  40. package/skills/teamsmith/scripts/panel/src/layout.ts +703 -152
  41. package/skills/teamsmith/scripts/panel/src/main.tsx +129 -19
  42. package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
  43. package/skills/teamsmith/scripts/panel/src/strings/en.ts +76 -31
  44. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +78 -33
  45. package/skills/teamsmith/scripts/panel/src/types.ts +204 -17
  46. package/skills/teamsmith/scripts/replies.mjs +896 -0
  47. package/skills/teamsmith/scripts/shim/tmux +18 -0
  48. package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
  49. package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
  50. package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
  51. package/skills/teamsmith/scripts/team +20 -6
  52. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +23 -3
  53. package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
  54. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
  55. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
  56. package/skills/teamsmith/templates/config.sh.tmpl +29 -5
  57. package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
  58. package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -1
  59. package/skills/teamsmith/templates/report.md.tmpl +12 -0
  60. package/skills/teamsmith/templates/task.md.tmpl +4 -0
  61. package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
  62. package/skills/teamsmith/tests/bg-ledger.sh +168 -10
  63. package/skills/teamsmith/tests/checkout-shape-probe.sh +3 -1
  64. package/skills/teamsmith/tests/config-cli.sh +320 -300
  65. package/skills/teamsmith/tests/death-cause.sh +5 -2
  66. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
  67. package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
  68. package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
  69. package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
  70. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
  71. package/skills/teamsmith/tests/flip-m33.sh +5 -3
  72. package/skills/teamsmith/tests/flip-m37.sh +4 -1
  73. package/skills/teamsmith/tests/flip-m4.3.sh +4 -1
  74. package/skills/teamsmith/tests/flip-m6.3.sh +4 -1
  75. package/skills/teamsmith/tests/flip-m6.5.sh +4 -1
  76. package/skills/teamsmith/tests/flip-m7.2.sh +4 -1
  77. package/skills/teamsmith/tests/flip-p158.sh +2 -1
  78. package/skills/teamsmith/tests/flip-p210.sh +4 -1
  79. package/skills/teamsmith/tests/flip-p217.sh +4 -1
  80. package/skills/teamsmith/tests/flip-p287-lock.sh +342 -0
  81. package/skills/teamsmith/tests/flip-p287-name.sh +279 -0
  82. package/skills/teamsmith/tests/flip-p304-read-side.sh +98 -0
  83. package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
  84. package/skills/teamsmith/tests/flip-p309-p162-deep.sh +122 -0
  85. package/skills/teamsmith/tests/flip-p310-lock.sh +216 -0
  86. package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
  87. package/skills/teamsmith/tests/help-surface.sh +1664 -0
  88. package/skills/teamsmith/tests/install-shape.sh +283 -22
  89. package/skills/teamsmith/tests/key-replies-pty.sh +374 -0
  90. package/skills/teamsmith/tests/key-replies-ui.sh +325 -0
  91. package/skills/teamsmith/tests/key-replies.sh +1314 -0
  92. package/skills/teamsmith/tests/ledger-ban.sh +9 -8
  93. package/skills/teamsmith/tests/ledger-claim.sh +248 -0
  94. package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
  95. package/skills/teamsmith/tests/lib/model-policy.sh +30 -0
  96. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
  97. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
  98. package/skills/teamsmith/tests/lib/model-routing-flips.py +187 -0
  99. package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
  100. package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
  101. package/skills/teamsmith/tests/lib/reply-fixture.sh +367 -0
  102. package/skills/teamsmith/tests/lib/section-guard.sh +258 -13
  103. package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
  104. package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
  105. package/skills/teamsmith/tests/lib/tmux-iso.sh +39 -13
  106. package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
  107. package/skills/teamsmith/tests/panel-b2.sh +107 -4
  108. package/skills/teamsmith/tests/panel-b3-stub.sh +139 -4
  109. package/skills/teamsmith/tests/panel-b3.sh +189 -29
  110. package/skills/teamsmith/tests/panel-choices.sh +81 -63
  111. package/skills/teamsmith/tests/panel-cpu.sh +3 -2
  112. package/skills/teamsmith/tests/panel-knobs.sh +7 -1
  113. package/skills/teamsmith/tests/panel-p21.sh +445 -241
  114. package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
  115. package/skills/teamsmith/tests/panel-strings.mjs +33 -18
  116. package/skills/teamsmith/tests/perf.sh +122 -31
  117. package/skills/teamsmith/tests/pm-box-real.sh +1 -1
  118. package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
  119. package/skills/teamsmith/tests/routes.sh +364 -109
  120. package/skills/teamsmith/tests/seat-interrupt.sh +1002 -0
  121. package/skills/teamsmith/tests/seat-visibility.sh +675 -0
  122. package/skills/teamsmith/tests/section-budgets.tsv +26 -12
  123. package/skills/teamsmith/tests/section-guard.sh +6 -1
  124. package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
  125. package/skills/teamsmith/tests/section-paths.tsv +42 -26
  126. package/skills/teamsmith/tests/section-select.sh +90 -7
  127. package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
  128. package/skills/teamsmith/tests/slash-team.sh +617 -0
  129. package/skills/teamsmith/tests/smoke.sh +3762 -628
  130. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
  131. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
  132. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
  133. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
  134. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
  135. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
  136. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
  137. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
  138. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
  139. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
  140. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
  141. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
  142. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
  143. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
  144. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
  145. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
  146. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
  147. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
  148. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
  149. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
  150. package/skills/teamsmith/tests/task-header-model.sh +2 -1
  151. package/skills/teamsmith/tests/task-model-routing.sh +1511 -0
  152. package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
  153. package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
  154. package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
  155. package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
  156. package/skills/teamsmith-init/SKILL.md +43 -43
  157. package/skills/teamsmith-init/references/bootstrap.md +8 -6
  158. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
@@ -33,7 +33,17 @@ import { clockOf } from './format.js'
33
33
  import { dispWidth } from './width.js'
34
34
  import type { Palette } from './theme.js'
35
35
  import type { Segment } from './types.js'
36
- import { BLOCK_NAMES, MACHINE_BLOCKS, cleanIdentityEnv, createPanelCache, findTeamCli, loadPanelData, panelDirOf, runTick } from './data.js'
36
+ import {
37
+ BLOCK_NAMES,
38
+ MACHINE_BLOCKS,
39
+ cleanIdentityEnv,
40
+ createPanelCache,
41
+ findTeamCli,
42
+ loadPanelData,
43
+ panelDirOf,
44
+ runTick,
45
+ type BlockName,
46
+ } from './data.js'
37
47
  import type { DataOptions, DataResult, PanelCache } from './data.js'
38
48
  import { normalizeNewlines, parseSendResult, mapReceipt, DRAFT_FILE } from './compose.js'
39
49
  import type { Receipt } from './compose.js'
@@ -44,7 +54,7 @@ import { fill, stringsFor } from './strings/index.js'
44
54
  import { PANEL_CONF_FILE, PANEL_PAGE_FILE, readPage, readSettings, writePage, writeSettings } from './settings.js'
45
55
  import type { Settings } from './settings.js'
46
56
  import { contrastPairs, PALETTES, resolveTheme } from './theme.js'
47
- import type { FrameInput, PageId, ViewState } from './types.js'
57
+ import type { FrameInput, PageId, ViewState, DetailSource } from './types.js'
48
58
 
49
59
  /** The Kitty keyboard protocol's pop/push pair, written around the editor handoff (design §6). */
50
60
  const KITTY_POP = '\u001b[<u'
@@ -99,12 +109,35 @@ function argOf(name: string): string | undefined {
99
109
 
100
110
  const has = (name: string): boolean => process.argv.includes(`--${name}`)
101
111
 
112
+ /**
113
+ * Write every byte to a raw fd. Node puts fd 1 (and 2) in non-blocking mode when it is a pipe, so a
114
+ * single `writeSync` of a whole frame may return a **short count** — the tail is then simply lost.
115
+ * Measured on this pinned stack: a 160-column `--snapshot` piped through `sed` dropped its last 462
116
+ * bytes roughly one run in five (a frame cut mid-character). A full-write loop is the fix; `EAGAIN`
117
+ * means the pipe's buffer is full, so wait a millisecond and continue instead of dropping the tail.
118
+ */
119
+ function writeAll(fd: number, text: string): void {
120
+ const buf = Buffer.from(text, 'utf8')
121
+ let off = 0
122
+ let spins = 0
123
+ while (off < buf.length) {
124
+ try {
125
+ off += writeSync(fd, buf, off, buf.length - off)
126
+ spins = 0
127
+ } catch (e) {
128
+ if ((e as NodeJS.ErrnoException)?.code !== 'EAGAIN') throw e
129
+ if (++spins > 10000) throw e // ~10s of a full pipe: fail loudly instead of spinning forever
130
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1)
131
+ }
132
+ }
133
+ }
134
+
102
135
  /** Machine-readable output must not be lost to an async pipe write. */
103
136
  function out(text: string): void {
104
- writeSync(1, text)
137
+ writeAll(1, text)
105
138
  }
106
139
  function fail(message: string): never {
107
- writeSync(2, `✗ ${message}\n`)
140
+ writeAll(2, `✗ ${message}\n`)
108
141
  process.exit(1)
109
142
  }
110
143
 
@@ -135,6 +168,23 @@ const pageArg = argOf('page')
135
168
  const langArg = argOf('lang')
136
169
  /** `--detail <ID>`: render the read-only detail view in a snapshot (the overlay's sibling exit). */
137
170
  const detailArg = argOf('detail') || ''
171
+ /**
172
+ * `--detail-source entry|spec|change|decision`: the source the snapshot's detail view addresses.
173
+ * Read-only and snapshot-only — the live console passes its source through `api.setDetail`. An
174
+ * unrecognised value is ignored (entry), so the argument cannot open a way out of the closed set.
175
+ */
176
+ const detailSourceRaw = argOf('detail-source') || ''
177
+ const detailSourceArg =
178
+ detailSourceRaw === 'spec' || detailSourceRaw === 'change' || detailSourceRaw === 'decision' ? detailSourceRaw : 'entry'
179
+ /**
180
+ * Page 5's snapshot/demand knobs (pulse-key-replies). `--reply-no N` opens that number's viewer,
181
+ * `--reply-before N` pins the list cursor and `--reply-focus N` pins the focused slot, so the
182
+ * snapshot matrix can render summary/list/empty/corrupt/continuation/long-body deterministically.
183
+ * They are read options only: nothing here writes to the store.
184
+ */
185
+ const replyNoArg = Number(argOf('reply-no') ?? 0) || 0
186
+ const replyBeforeArg = Number(argOf('reply-before') ?? 0) || 0
187
+ const replyFocusArg = Number(argOf('reply-focus') ?? 0) || 0
138
188
 
139
189
  if (has('version')) {
140
190
  out(`teamsmith panel ${PANEL_VERSION} · ink ${PIN_INK} · react ${PIN_REACT}\nbuilt by: ${BUILD_CMD}\n`)
@@ -144,7 +194,8 @@ if (has('help')) {
144
194
  out(
145
195
  'usage: panel.js [--root DIR] [--state-dir DIR] [--print|--json|--once|--headless|--snapshot|--palette]\n' +
146
196
  ' [--width N] [--height N] [--activity|--no-activity] [--events N] [--refresh N]\n' +
147
- ' [--no-pulse] [--theme dark|light] [--page 1|2|3|4] [--lang zh|en] [--overlay] [--detail ID] [--version]\n',
197
+ ' [--no-pulse] [--theme dark|light] [--page 1|2|3|4|5] [--lang zh|en] [--overlay] [--detail ID] [--detail-source entry|spec|change|decision]\n' +
198
+ ' [--reply-no N] [--reply-before N] [--reply-focus N] [--version]\n',
148
199
  )
149
200
  process.exit(0)
150
201
  }
@@ -242,6 +293,7 @@ function frameOf(res: DataResult, activity: boolean, scroll?: number): FrameInpu
242
293
  activityBlocks: activity ? res.activity ?? [] : [],
243
294
  blocks: res.blocks ?? {},
244
295
  degraded: res.degraded ?? [],
296
+ replyBodyFailed: Boolean(res.errors?.reply_body),
245
297
  width: widthArg || stdoutColumns || 100,
246
298
  height: heightArg || stdoutRows || 0,
247
299
  activity,
@@ -290,14 +342,31 @@ async function main(): Promise<void> {
290
342
  const settings = readSettings(confFile)
291
343
  const themeName = themeArg === 'dark' || themeArg === 'light' ? themeArg : resolveTheme(settings.theme)
292
344
  const lang = langArg === 'en' || langArg === 'zh' ? langArg : settings.lang
293
- const page = pageArg === '1' || pageArg === '2' || pageArg === '3' || pageArg === '4' ? (Number(pageArg) as PageId) : settings.defaultPage
294
- const res = await loadPanelData({ root, teamCli, activity: rawActivityOn, events, detailId: detailArg || null })
345
+ const page =
346
+ pageArg === '1' || pageArg === '2' || pageArg === '3' || pageArg === '4' || pageArg === '5'
347
+ ? (Number(pageArg) as PageId)
348
+ : settings.defaultPage
349
+ // Page 5's demand reads are handed to the assembly exactly as the App hands them over: the list
350
+ // only for the cursor in view, the body only while the viewer is open.
351
+ const res = await loadPanelData({
352
+ root,
353
+ teamCli,
354
+ activity: rawActivityOn,
355
+ events,
356
+ detailId: detailArg || null,
357
+ detailSource: detailArg ? detailSourceArg : null,
358
+ replyListOpen: page === 5 && !replyNoArg,
359
+ replyBefore: replyBeforeArg || null,
360
+ replyNo: page === 5 && replyNoArg ? replyNoArg : null,
361
+ })
295
362
  const frame = frameOrFail(res, rawActivityOn)
296
363
  const view: ViewState = {
297
364
  ...defaultView(lang, page),
298
365
  tui: true,
299
366
  mouseOn: settings.mouse,
300
367
  density: settings.density,
368
+ replyFocus: replyFocusArg || null,
369
+ replyBody: replyNoArg || null,
301
370
  overlay: wantOverlay,
302
371
  detail: detailArg || null,
303
372
  // P123: the snapshot is the TUI's own render path, so it reads the fold keys (the machine exits
@@ -335,7 +404,7 @@ async function main(): Promise<void> {
335
404
  // `--page` is honoured here too (P123's machine-frame identity fixture renders page 4); absent,
336
405
  // the machine frame stays the overview it always was.
337
406
  const machinePage: PageId =
338
- pageArg === '1' || pageArg === '2' || pageArg === '3' || pageArg === '4' ? (Number(pageArg) as PageId) : 1
407
+ pageArg === '1' || pageArg === '2' || pageArg === '3' || pageArg === '4' || pageArg === '5' ? (Number(pageArg) as PageId) : 1
339
408
  if (once || wantPrint) {
340
409
  // One frame; `--once` then keeps today's tick semantics, `--print` (the observer) never ticks.
341
410
  const frame = frameOrFail(await loadPanelData({ root, teamCli, activity: rawActivityOn, events, blocks: MACHINE_BLOCKS }), rawActivityOn, MACHINE_BLOCKS)
@@ -431,12 +500,19 @@ async function main(): Promise<void> {
431
500
  return ''
432
501
  }
433
502
  }
434
- function writeDraft(text: string): void {
503
+ /**
504
+ * Write `state/draft.md`. Returns whether the write landed: the send settle empties the file first
505
+ * and must know the result before it may drop the in-memory draft (change
506
+ * panel-preview-and-compose — memory and disk never disagree about the draft).
507
+ */
508
+ function writeDraft(text: string): boolean {
435
509
  try {
436
510
  mkdirSync(stateDir, { recursive: true })
437
511
  writeFileSync(draftFile, String(text ?? ''))
512
+ return true
438
513
  } catch {
439
514
  /* a state directory the console cannot write must not kill the panel */
515
+ return false
440
516
  }
441
517
  }
442
518
 
@@ -539,14 +615,18 @@ async function main(): Promise<void> {
539
615
  return { code: res.rc, line }
540
616
  }
541
617
 
542
- /** One `team config set-agent-model <seat> <model|->` invocation (P22/B4). */
543
- async function setSeatModel(
544
- seat: string,
618
+ /**
619
+ * One `team config set-task-model <category> <model>` invocation (P232): a category row edits one
620
+ * mapping entry through the owning command — the console never composes or writes the pair list
621
+ * itself. Same dry-run/CAS/actor panel contract as `setSetting`.
622
+ */
623
+ async function setTaskModel(
624
+ category: string,
545
625
  model: string,
546
626
  o: { dryRun?: boolean; fingerprint?: string | null },
547
627
  ): Promise<{ code: number; line: string }> {
548
628
  if (!teamCli) return { code: 127, line: s.noTeamCli }
549
- const args = [teamCli, '--root', root, 'config', 'set-agent-model', seat, model || '-', '--actor', 'panel']
629
+ const args = [teamCli, '--root', root, 'config', 'set-task-model', category, model, '--actor', 'panel']
550
630
  if (o.dryRun) args.push('--dry-run')
551
631
  else args.push('--yes')
552
632
  if (o.fingerprint) args.push('--fingerprint', o.fingerprint)
@@ -720,7 +800,7 @@ async function main(): Promise<void> {
720
800
  const api: PanelApi = {
721
801
  readDraft,
722
802
  writeDraft,
723
- clearDraft: () => writeDraft(''),
803
+ clearDraft: (): boolean => writeDraft(''),
724
804
  send,
725
805
  flushQueue,
726
806
  setStandby,
@@ -733,7 +813,8 @@ async function main(): Promise<void> {
733
813
  const read = await readClipboard(clipRunner)
734
814
  if (!read) return { kind: 'none' as const, value: '' }
735
815
  if (read.kind === 'text') return { kind: 'text' as const, value: read.text }
736
- const file = writePasteFile(read.bytes, read.mime)
816
+ // P309: the paste path uses the resolved temp root the data layer reports (no second resolution).
817
+ const file = writePasteFile(read.bytes, read.mime, cache.snapshot().data?.capacity?.temp_root)
737
818
  if (!file) return { kind: 'none' as const, value: '' }
738
819
  return { kind: 'path' as const, value: file }
739
820
  },
@@ -755,23 +836,52 @@ async function main(): Promise<void> {
755
836
  opts.activity = on
756
837
  refreshNow()
757
838
  },
758
- setDetail: (id: string | null, file?: string | null) => {
839
+ setDetail: (id: string | null, file?: string | null, source?: DetailSource | null) => {
759
840
  const nextId = id ?? null
760
841
  const nextFile = nextId ? file ?? null : null
761
- if ((opts.detailId ?? null) === nextId && (opts.detailFile ?? null) === nextFile) return
842
+ const nextSource: DetailSource = nextId ? source ?? 'entry' : 'entry'
843
+ if (
844
+ (opts.detailId ?? null) === nextId &&
845
+ (opts.detailFile ?? null) === nextFile &&
846
+ (opts.detailSource ?? 'entry') === nextSource
847
+ )
848
+ return
762
849
  opts.detailId = nextId
763
850
  opts.detailFile = nextFile
851
+ opts.detailSource = nextSource
764
852
  // The detail block is off the tick path: only the view's own open/tab-switch forces a build.
765
853
  if (!nextId) return
766
854
  // The cached block already serves this file (the open returns the first file without
767
- // `--file`): record the option and rebuild nothing, so the effect can stay idempotent.
855
+ // `--file`): record the option and rebuild nothing, so the effect can stay idempotent. The
856
+ // source is part of the identity — the same id from two sources is two different reads.
768
857
  const cached = cache.snapshot().blocks?.detail
769
858
  if (cached?.id === nextId && nextFile && cached.file === nextFile) return
770
859
  void cache.refresh({ force: true, only: ['detail'] }).then(adopt)
771
860
  },
861
+ /**
862
+ * Page 5's demand reads: record the cursor/number as cache options and force exactly the block
863
+ * that changed. An unchanged pair (a re-render, the same page) rebuilds nothing — the effect in
864
+ * the App may run freely. Clearing both drops the blocks from the wanted set, so a parked page
865
+ * spawns no list/body child at all.
866
+ */
867
+ setReply: ({ list, before, no }: { list: boolean; before: number | null; no: number | null }) => {
868
+ const nextBefore = before ?? null
869
+ const nextNo = no ?? null
870
+ const listChanged = Boolean(opts.replyListOpen) !== Boolean(list) || (opts.replyBefore ?? null) !== nextBefore
871
+ const noChanged = (opts.replyNo ?? null) !== nextNo
872
+ if (!listChanged && !noChanged) return
873
+ opts.replyListOpen = Boolean(list)
874
+ opts.replyBefore = nextBefore
875
+ opts.replyNo = nextNo
876
+ const only: BlockName[] = []
877
+ if (listChanged && list) only.push('reply_list')
878
+ if (noChanged && nextNo != null) only.push('reply_body')
879
+ if (!only.length) return
880
+ void cache.refresh({ force: true, only }).then(adopt)
881
+ },
772
882
  collapse,
773
883
  setSetting,
774
- setSeatModel,
884
+ setTaskModel,
775
885
  /**
776
886
  * The path kind's existence mark (M55): resolved against the project root (`~` honoured), the
777
887
  * rule from the command's own note. `not-exec` is only reachable for `exec` — a directory is
@@ -52,7 +52,7 @@ function boolOf(value: string): boolean | null {
52
52
 
53
53
  function pageOf(value: string): PageId | null {
54
54
  const v = value.trim()
55
- if (v === '1' || v === '2' || v === '3' || v === '4') return Number(v) as PageId
55
+ if (v === '1' || v === '2' || v === '3' || v === '4' || v === '5') return Number(v) as PageId
56
56
  return null
57
57
  }
58
58
 
@@ -76,6 +76,12 @@ export const en = {
76
76
  pageWork: 'work',
77
77
  pageMessages: 'messages & logs',
78
78
  pageBoard: 'board',
79
+ pageReplies: 'key replies',
80
+ pageOverviewShort: 'overview',
81
+ pageWorkShort: 'work',
82
+ pageMessagesShort: 'msgs',
83
+ pageBoardShort: 'board',
84
+ pageRepliesShort: 'replies',
79
85
  pageTab: ' {name} ',
80
86
  pageTabActive: '▸{name}◂',
81
87
 
@@ -93,6 +99,7 @@ export const en = {
93
99
  // Detail view (read-only)
94
100
  detailTitle: 'detail {id}',
95
101
  detailNoFiles: '(no associated files for this entry)',
102
+ detailUnavailable: '(source unavailable: {reason})',
96
103
  detailTruncated: '… truncated (first 128 KiB shown)',
97
104
  detailLoading: '… loading',
98
105
 
@@ -175,22 +182,22 @@ export const en = {
175
182
  group_branch: 'Branch & forge',
176
183
  group_policy: 'Permissions & dependencies',
177
184
  group_roster: 'Roster, models & adapters',
178
- 'group_seat-model': 'Per-seat models',
185
+ 'group_task-model': 'Task categories & PM model',
179
186
  group_workflow: 'Workflow & gates',
180
187
  group_delivery: 'Capacity & delivery',
181
188
  group_panel: 'Pulse & panel',
182
- group_patrol: 'Patrol policy',
189
+ group_patrol: 'Patrol',
183
190
  'group_pm-lifecycle': 'PM lifecycle',
184
191
  group_session: 'Live sessions',
185
192
  group_meeting: 'Cross-project meetings',
186
193
  settingsGroupUngrouped: 'Ungrouped',
187
- settingsGroupSeats: 'Seats',
194
+ settingsGroupCategories: 'The model the next task will use',
195
+ settingsGroupAssignments: 'The model running tasks actually use',
188
196
  settingsBadgeApply: 'apply',
189
197
  settingsBadgeRestart: 'restart',
190
- settingsBadgeRefuse: 'read-only',
191
- settingsUnknownBadge: 'unknown key',
198
+ settingsBadgeRefuse: 'change in file',
199
+ settingsUnknownBadge: 'not recognized',
192
200
  settingsUnset: 'unset · default {value}',
193
- settingsAuditHeading: 'Audit (newest)',
194
201
  settingsKeyHint: '↑/↓ rows · Enter edit · / filter · Esc back',
195
202
  keyFilter: '/ filter',
196
203
  settingFilterTitle: 'Filter settings',
@@ -200,44 +207,52 @@ export const en = {
200
207
  settingDanger: 'Danger: {reason} (press Enter once more to confirm)',
201
208
  settingRejected: '✗ refused: {line}',
202
209
  settingWritten: '✓ wrote {key} = {value} · {timing}',
203
- settingRefused: '✗ read-only key: {line}',
210
+ settingRefused: '✗ this value is changed in the project config file: {line}',
204
211
  settingInvalid: '✗ invalid value: {line}',
205
212
  settingConflict: '! the contract changed under the editor (fingerprint mismatch) — nothing written; reloaded',
206
213
  settingWriteError: '✗ write failed (file unchanged): {line}',
207
- settingsRefusedRoute: 'read-only key: edit .pi/team/config.sh by hand',
208
- settingsSeatHint: 'seat model: team config set-agent-model {seat} <model>',
209
- settingsPairlistHint: 'seat models: team config set-agent-model <seat> <model|-> — this row’s editor is the seats block (Enter moves there; the pair list is never composed here)',
214
+ settingsRefusedRoute: 'change this value in the project config file .pi/team/config.sh; the panel cannot change it',
215
+ settingsCategoryHint: 'category {category}: team config set-task-model {category} <model> — new tasks only; a task already dispatched keeps the model it was given (this row never composes the map)',
216
+ settingsCategoryRow: 'category {category}',
217
+ settingsCategoryModel: 'model {model}',
218
+ settingsCategoryBadge: 'new tasks',
219
+ settingsCategoryPickerTitle: 'Pick the model for category {category}',
220
+ settingsCategoryPickerHint: '↑/↓ choose · Enter writes that value now · only free text opens the editor · Esc back (new tasks only; a task already dispatched keeps the model it was given and no process is restarted)',
221
+ settingsCategoryMapHint: 'the categories block is this row’s editor (command: team config set-task-model <category> <model>) — the pair list is never composed in the console',
222
+ settingsCategoryMapEmpty: 'the categories block is this row’s editor (command: team config set-task-model <category> <model>) — the map is empty today; add a category through the CLI first',
223
+ settingsAssignmentHint: 'once a task is dispatched it keeps the model it was given; this setting does not change it',
224
+ settingsAssignmentNote: 'task {task} · category {category} · session {sid} · origin {selected}/{launch}',
225
+ settingsAssignmentNone: 'this seat has not been given a task yet',
226
+ settingsAssignmentUnreadable: 'this seat was given a task, but its record could not be read, so the panel does not show its model',
227
+ settingsReadOnlyBadge: 'change in file',
228
+ settingsPmLaunchLabel: 'last PM start',
229
+ settingsPmLaunchNote: 'window {window} · {mode} · {time}',
230
+ settingsPmLaunchHint: 'the model the PM used the last time it started; it cannot be changed here',
231
+ settingsDiagnosisHeading: 'these settings need an upgrade',
210
232
  settingsCliHint: 'CLI: team config set {key} <value>',
211
- settingsRefusedHint: 'read-only: edit {key} in .pi/team/config.sh by hand',
212
- settingsUnknownHint: 'unknown key: {key} is in the file but not in the command schema',
233
+ settingsRefusedHint: 'change this value in the project config file .pi/team/config.sh; the panel cannot change it',
234
+ settingsUnknownHint: '{key}: the file carries this setting but the tool does not know it; the panel cannot change it',
213
235
  settingsChoiceTitle: 'Choose a value for {label} · {key}',
214
236
  settingsChoiceHint: '↑/↓ choose · Enter writes that value now (danger needs one more) · only free text opens the editor · Esc back',
215
237
  settingsChoiceCurrent: 'current',
216
238
  settingsChoiceDefault: 'default',
217
- settingsChoiceKeepUnset: 'keep unset (cancel writes nothing and leaves no audit line)',
239
+ settingsChoiceKeepUnset: 'keep unset (cancel, nothing written)',
218
240
  settingsChoiceClear: 'clear (write the empty value)',
219
241
  settingsChoiceFree: '… (free text)',
220
242
  settingsChoiceInterval: 'accepted interval {min}–{max} (empty = unbounded)',
221
243
  settingsChoiceNoChoice: 'the kind {kind} has no choice set; the command still validates the write (Enter opens free text)',
222
- settingsChoicePairlist: 'The seats block is this row’s editor (command: team config set-agent-model <seat> <model|->)',
244
+ settingCategoryConfirm: 'Confirm category {category}: {old} → {next} · new tasks only; a task already dispatched keeps the model it was given (Enter again to write)',
245
+ settingCategoryWritten: '✓ wrote category {category} = {value} · new tasks only; tasks already dispatched keep the model they were given; no process was restarted',
246
+ settingPmWritten: '✓ wrote the PM model = {value} · changing the model needs team up --fresh-pm, which starts a new conversation; no process was restarted',
223
247
  settingsBoolOn: 'on (1)',
224
248
  settingsBoolOff: 'off (0)',
225
249
  settingsPathExists: 'exists',
226
250
  settingsPathMissing: 'missing',
227
251
  settingsPathNotExec: 'not executable',
228
- seatPickerTitle: 'Pick the model for {seat}',
229
- seatPickerHint: '↑/↓ select · Enter edit that value · Esc back (a running window keeps its model until the next dispatch/resume)',
230
- seatPickerRemove: '- (remove the override, fall back to the default)',
231
- seatPickerFree: '… (free text provider/model)',
232
- settingSeatConfirm: 'Confirm seat {seat}: {old} → {next} · takes effect on the next dispatch/resume (a running window keeps its model) (Enter again to write)',
233
- settingSeatWritten: '✓ wrote seat {seat} = {value} · effective on the next dispatch/resume',
234
- settingSeatRemoved: '✓ removed the override of seat {seat} · back to the default {value}',
235
- keySeatPick: 'Enter select',
236
- seatSourceConfig: 'config',
237
- seatSourceExplicit: 'explicit',
238
- seatSourceRecord: 'stale record',
239
- seatOverride: 'override',
240
- seatFallback: 'fallback',
252
+ keyCategoryPick: 'Enter edit',
253
+ seatSourceExplicit: 'chosen at dispatch',
254
+ seatSourcePolicy: 'set by category',
255
+ seatSourceAssignment: 'kept from the record',
241
256
 
242
257
  // The human labels of the contract keys (M49): one per key of `lib/cmd-config.sh`'s schema, and
243
258
  // the row's main text — the bare TEAM_* stays where it aligns with the CLI (the editor's title,
@@ -256,6 +271,7 @@ export const en = {
256
271
  label_TEAM_SPEC_DIR: 'Spec dir',
257
272
  label_TEAM_ROOT: 'Project root',
258
273
  label_TEAM_MAIN_ROOT: 'Main checkout root',
274
+ label_TEAM_TMP_ROOT: 'Temp root',
259
275
  label_TEAM_CONFIG_FILE: 'Contract file',
260
276
  // -- branch and forge (read-only)
261
277
  label_TEAM_BRANCH_MODE: 'Branch naming mode',
@@ -297,11 +313,12 @@ export const en = {
297
313
  label_TEAM_AGENT_BIN: 'Seat binary',
298
314
  label_TEAM_OPENSPEC_BIN: 'openspec binary',
299
315
  label_TEAM_JS_BIN: 'JS runtime',
300
- // -- per-seat models (needs a restart)
301
- label_TEAM_DEFAULT_MODEL: 'Default model',
302
- label_TEAM_AGENT_MODELS: 'Per-seat models',
316
+ // -- task categories and the PM model (apply/restart)
317
+ label_TEAM_TASK_MODELS: 'Task category models',
303
318
  label_TEAM_PM_MODEL: 'PM model',
319
+ label_TEAM_CONFIG_VERSION: 'Config shape version',
304
320
  // -- workflow and gates
321
+ label_TEAM_UPDATE_CHECK: 'Startup version notice',
305
322
  label_TEAM_GATES: 'Gate commands',
306
323
  label_TEAM_INSTALL_CMD: 'Install command',
307
324
  label_TEAM_TASK_BRANCH_RESET: 'Reset task branch',
@@ -329,9 +346,13 @@ export const en = {
329
346
  label_TEAM_NOTIFY_DEDUP_SEC: 'Notify dedup window',
330
347
  label_TEAM_INBOX_MAX_CHARS: 'Inbox summary chars',
331
348
  label_TEAM_NOTIFY_LOG: 'Notify debug log',
349
+ label_TEAM_NOTIFY_DETAIL_MAX: 'Notify detail bound',
332
350
  label_TEAM_DEFER_TTL: 'Queued delivery TTL',
333
351
  label_TEAM_OUTBOX_MAX: 'Outbox cap',
334
352
  label_TEAM_PANEL_DETAIL_CAP: 'Detail read cap',
353
+ label_TEAM_ORPHAN_WARN_MB: 'Orphan memory hint',
354
+ label_TEAM_ORPHAN_SCAN: 'Scan orphan seats',
355
+ label_TEAM_ORPHAN_PROC_ROOT: 'Census proc root',
335
356
  // -- pulse and panel (needs a restart)
336
357
  label_TEAM_PULSE_INTERVAL: 'Patrol interval',
337
358
  label_TEAM_MONITOR_REFRESH: 'Panel refresh period',
@@ -375,12 +396,35 @@ export const en = {
375
396
  label_TEAM_MEETING_KNOCK: 'Allow knocking',
376
397
  label_TEAM_MEETING_ALLOW_USER_ID: 'Users who may knock',
377
398
 
399
+ // Key replies (pulse-key-replies)
400
+ replyHeading: 'key replies',
401
+ replyHeadingCount: 'key replies ({n})',
402
+ replyLatest: 'latest key reply',
403
+ replyEmpty: '(no key replies yet)',
404
+ replyUnavailable: '(unavailable)',
405
+ replyLatestUnavailable: 'latest reply unavailable: {reason}',
406
+ replyDeclared: 'from {from} · {at}',
407
+ replyDeclaredShort: 'from {from}',
408
+ replySlotUnavailable: '#{no} unavailable',
409
+ replyLoading: '… loading',
410
+ replyBodyMissing: 'this reply is unavailable',
411
+ replyBodyHint: 'read-only · shown as published',
412
+ replyOlder: 'Older',
413
+ replyNewer: 'Newer',
414
+ replyBack: 'Back',
415
+ replyScrollHint: '↑/↓ PgUp/PgDn Home/End scroll',
416
+ replyTotalSlots: '{n} numbered slots',
417
+ replyTailWarning: 'the index tail is incomplete (the last append did not finish)',
418
+ replyPageNote: '"who is this reply written for?" — replies the PM wrote for the user',
419
+
378
420
  // Global keys (footer)
379
421
  keyCompose: 'm compose',
380
422
  keyFlush: 'f flush',
381
423
  keyStandby: 's standby',
382
424
  keySettings: ', settings',
383
- keyPages: 'Tab/1-4 pages',
425
+ keyPages: 'Tab/1-5 pages',
426
+ keyReplies: '←/→ older/newer',
427
+ keyReplyReset: 'r newest',
384
428
  keyScroll: '↑/↓ scroll',
385
429
  keyLanes: '←/→ lanes',
386
430
  keyCards: '↑/↓ cards',
@@ -402,6 +446,7 @@ export const en = {
402
446
  receiptQueued: '… queued (the PM is typing) · queued',
403
447
  receiptHeld: '! held (copy under state/outbox/held/) · held',
404
448
  receiptError: '✗ delivery unconfirmed · {detail}',
449
+ draftNotCleared: '✗ settled, but the draft file could not be emptied: {file} (the text stays in the input line)',
405
450
  flushOk: '✓ flush · {detail}',
406
451
  flushFail: '✗ flush failed · {detail}',
407
452
  standbyOkOn: '✓ standby on (reason: {reason})',