teamsmith 0.1.2 → 0.2.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 (97) hide show
  1. package/README.md +13 -7
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +39 -0
  4. package/skills/teamsmith/SKILL.md +18 -7
  5. package/skills/teamsmith/references/agent-adapters.md +7 -7
  6. package/skills/teamsmith/references/config.md +29 -15
  7. package/skills/teamsmith/references/migration.md +38 -2
  8. package/skills/teamsmith/references/protocol.md +81 -13
  9. package/skills/teamsmith/references/workflows.md +31 -19
  10. package/skills/teamsmith/scripts/lib/cmd-agents.sh +210 -70
  11. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +70 -9
  12. package/skills/teamsmith/scripts/lib/cmd-config.sh +222 -70
  13. package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
  14. package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
  15. package/skills/teamsmith/scripts/lib/cmd-project.sh +134 -17
  16. package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
  17. package/skills/teamsmith/scripts/lib/cmd-review.sh +13 -10
  18. package/skills/teamsmith/scripts/lib/cmd-status.sh +42 -13
  19. package/skills/teamsmith/scripts/lib/cmd-watch.sh +75 -13
  20. package/skills/teamsmith/scripts/lib/common.sh +797 -71
  21. package/skills/teamsmith/scripts/monitor.mjs +34 -3
  22. package/skills/teamsmith/scripts/panel/README.md +22 -11
  23. package/skills/teamsmith/scripts/panel/panel.js +217 -215
  24. package/skills/teamsmith/scripts/panel/src/App.tsx +421 -164
  25. package/skills/teamsmith/scripts/panel/src/data.ts +84 -4
  26. package/skills/teamsmith/scripts/panel/src/layout.ts +502 -91
  27. package/skills/teamsmith/scripts/panel/src/main.tsx +97 -12
  28. package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
  29. package/skills/teamsmith/scripts/panel/src/strings/en.ts +56 -21
  30. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +56 -21
  31. package/skills/teamsmith/scripts/panel/src/types.ts +178 -16
  32. package/skills/teamsmith/scripts/replies.mjs +893 -0
  33. package/skills/teamsmith/scripts/team +1 -0
  34. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +15 -2
  35. package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
  36. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
  37. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
  38. package/skills/teamsmith/templates/config.sh.tmpl +10 -5
  39. package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
  40. package/skills/teamsmith/templates/pm-prompt.md.tmpl +20 -1
  41. package/skills/teamsmith/templates/report.md.tmpl +12 -0
  42. package/skills/teamsmith/templates/task.md.tmpl +4 -0
  43. package/skills/teamsmith/tests/config-cli.sh +162 -288
  44. package/skills/teamsmith/tests/death-cause.sh +5 -2
  45. package/skills/teamsmith/tests/install-shape.sh +4 -2
  46. package/skills/teamsmith/tests/key-replies-pty.sh +375 -0
  47. package/skills/teamsmith/tests/key-replies-ui.sh +332 -0
  48. package/skills/teamsmith/tests/key-replies.sh +1075 -0
  49. package/skills/teamsmith/tests/ledger-ban.sh +4 -4
  50. package/skills/teamsmith/tests/ledger-claim.sh +247 -0
  51. package/skills/teamsmith/tests/lib/model-policy.sh +26 -0
  52. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
  53. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
  54. package/skills/teamsmith/tests/lib/model-routing-flips.py +136 -0
  55. package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
  56. package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
  57. package/skills/teamsmith/tests/lib/reply-fixture.sh +372 -0
  58. package/skills/teamsmith/tests/lib/tmux-iso.sh +8 -0
  59. package/skills/teamsmith/tests/panel-b2.sh +1 -1
  60. package/skills/teamsmith/tests/panel-b3-stub.sh +27 -0
  61. package/skills/teamsmith/tests/panel-b3.sh +14 -10
  62. package/skills/teamsmith/tests/panel-choices.sh +74 -61
  63. package/skills/teamsmith/tests/panel-cpu.sh +1 -1
  64. package/skills/teamsmith/tests/panel-p21.sh +311 -190
  65. package/skills/teamsmith/tests/perf.sh +1 -1
  66. package/skills/teamsmith/tests/pm-box-real.sh +1 -1
  67. package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
  68. package/skills/teamsmith/tests/routes.sh +43 -22
  69. package/skills/teamsmith/tests/section-budgets.tsv +8 -4
  70. package/skills/teamsmith/tests/section-paths.tsv +26 -16
  71. package/skills/teamsmith/tests/section-select.sh +82 -6
  72. package/skills/teamsmith/tests/smoke.sh +782 -180
  73. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
  74. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
  75. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
  76. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
  77. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
  78. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
  79. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
  80. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
  81. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
  82. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
  83. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
  84. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
  85. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
  86. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
  87. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
  88. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
  89. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
  90. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
  91. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
  92. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
  93. package/skills/teamsmith/tests/task-header-model.sh +2 -1
  94. package/skills/teamsmith/tests/task-model-routing.sh +1014 -0
  95. package/skills/teamsmith-init/SKILL.md +38 -38
  96. package/skills/teamsmith-init/references/bootstrap.md +6 -4
  97. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
@@ -77,6 +77,13 @@ export const BLOCK_NAMES = [
77
77
  // P22/B2: the project-settings view's on-demand reader (`team config list --json`). Same rule:
78
78
  // never wanted unless the view is open.
79
79
  'settings',
80
+ // pulse-key-replies: the three console-only reply readers over the bounded helper. The summary is
81
+ // the one scheduled everywhere (the overview renders it); the list is wanted only on page 5 and
82
+ // the body only while the reply viewer is open (`opts.replyBefore` / `opts.replyNo`), so a parked
83
+ // console spawns no list/body child at all.
84
+ 'reply_summary',
85
+ 'reply_list',
86
+ 'reply_body',
80
87
  ] as const
81
88
  export type BlockName = (typeof BLOCK_NAMES)[number]
82
89
 
@@ -117,6 +124,12 @@ export interface DataOptions {
117
124
  settingsOpen?: boolean
118
125
  /** The detail file to serve with `--file` (must be one of the discovered paths). */
119
126
  detailFile?: string | null
127
+ /** True while page 5's list is the surface in view (the demand flag, beside the cursor). */
128
+ replyListOpen?: boolean
129
+ /** Page 5's list cursor (`--before <no>`); null/absent = the newest page. */
130
+ replyBefore?: number | null
131
+ /** The open reply viewer's number (`--no <no>`); null/absent = the viewer is closed. */
132
+ replyNo?: number | null
120
133
  }
121
134
 
122
135
  export interface DataResult {
@@ -188,6 +201,22 @@ const BLOCK_SPECS: Record<BlockName, BlockSpec> = {
188
201
  },
189
202
  // The project-settings reader rides the open view exactly like `detail` (P22/B2).
190
203
  settings: { ttlMs: 15000, timeoutMs: 10000 },
204
+ // Key replies (pulse-key-replies). The summary refreshes on the background cadence; the list is
205
+ // a demand read whose TTL only covers a re-render (its request key changes with the cursor and
206
+ // clears the cached value); the body is requested once per open number and only while the viewer
207
+ // is up. Budgets (design §4): summary 16 KiB / list 512 KiB / body 1 MiB of child stdout — the
208
+ // output cap below is the 32 MiB frame-wide backstop, the readers' own caps are the real bound.
209
+ reply_summary: { ttlMs: 15000, timeoutMs: 10000 },
210
+ reply_list: {
211
+ ttlMs: 15000,
212
+ timeoutMs: 10000,
213
+ extraArgs: (opts) => (opts.replyBefore ? ['--before', String(opts.replyBefore)] : []),
214
+ },
215
+ reply_body: {
216
+ ttlMs: 15000,
217
+ timeoutMs: 10000,
218
+ extraArgs: (opts) => (opts.replyNo ? ['--no', String(opts.replyNo)] : []),
219
+ },
191
220
  }
192
221
 
193
222
 
@@ -221,6 +250,7 @@ function runBlock(
221
250
  opts: DataOptions,
222
251
  cli: string,
223
252
  children?: Set<ReturnType<typeof spawn>>,
253
+ onChild?: (child: ReturnType<typeof spawn>) => void,
224
254
  ): Promise<BlockOutcome> {
225
255
  const timeoutMs = opts.timeoutMs ?? spec.timeoutMs
226
256
  const extra = spec.extraArgs ? spec.extraArgs(opts) : []
@@ -230,6 +260,7 @@ function runBlock(
230
260
  try {
231
261
  child = spawn('bash', args, { cwd: opts.root, env: cleanIdentityEnv(), stdio: ['ignore', 'pipe', 'pipe'] })
232
262
  children?.add(child)
263
+ onChild?.(child)
233
264
  } catch (e) {
234
265
  resolve({ ok: false, error: (e as Error).message })
235
266
  return
@@ -344,6 +375,8 @@ interface BlockState {
344
375
  /** Epoch ms of the last successful build (0 = never). */
345
376
  at: number
346
377
  error?: string
378
+ /** The request key the cached value was built for (`reply_list` cursor / `reply_body` number). */
379
+ key?: string
347
380
  }
348
381
 
349
382
  const PANEL_BLOCK_NAMES: readonly BlockName[] = [
@@ -357,6 +390,9 @@ const PANEL_BLOCK_NAMES: readonly BlockName[] = [
357
390
  'health',
358
391
  'detail',
359
392
  'settings',
393
+ 'reply_summary',
394
+ 'reply_list',
395
+ 'reply_body',
360
396
  ]
361
397
 
362
398
  function isPanelBlock(name: BlockName): boolean {
@@ -388,8 +424,29 @@ export function createPanelCache(opts: DataOptions): PanelCache {
388
424
  const live = new Set<BlockName>()
389
425
  if (opts.detailId) live.add('detail')
390
426
  if (opts.settingsOpen) live.add('settings')
391
- return BLOCK_NAMES.filter((name) => (name === 'detail' || name === 'settings' ? live.has(name) : true))
427
+ if (opts.replyListOpen) live.add('reply_list')
428
+ if (opts.replyNo) live.add('reply_body')
429
+ const demand = new Set<BlockName>(['detail', 'settings', 'reply_list', 'reply_body'])
430
+ return BLOCK_NAMES.filter((name) => (demand.has(name) ? live.has(name) : true))
431
+ }
432
+
433
+ /**
434
+ * The **request key** of one block (`reply_list` = its cursor, `reply_body` = its number).
435
+ * Changing it clears the cached value and the error, cancels the child still in flight and makes
436
+ * any late response for the old key a no-op: a late page or body must never replace the selection
437
+ * the user is looking at (design §4).
438
+ */
439
+ const requestKey = (name: BlockName): string => {
440
+ switch (name) {
441
+ case 'reply_list':
442
+ return `open:${opts.replyListOpen ? 1 : 0}:before:${opts.replyBefore ?? 'newest'}`
443
+ case 'reply_body':
444
+ return `no:${opts.replyNo ?? 'none'}`
445
+ default:
446
+ return ''
447
+ }
392
448
  }
449
+ const blockChildren: Partial<Record<BlockName, ReturnType<typeof spawn>>> = {}
393
450
  const state: Record<string, BlockState> = {}
394
451
  for (const name of BLOCK_NAMES) state[name] = { at: 0 }
395
452
  let inFlight: Partial<Record<BlockName, Promise<void>>> = {}
@@ -427,9 +484,12 @@ export function createPanelCache(opts: DataOptions): PanelCache {
427
484
  return { ok: true, data, activity, blocks, degraded, errors }
428
485
  }
429
486
 
430
- function build(name: BlockName): Promise<void> {
431
- return runBlock(BLOCK_SPECS[name], name, opts, cli as string, children).then((outcome) => {
487
+ function build(name: BlockName, key: string): Promise<void> {
488
+ return runBlock(BLOCK_SPECS[name], name, opts, cli as string, children, (child) => {
489
+ blockChildren[name] = child
490
+ }).then((outcome) => {
432
491
  const s = state[name]
492
+ if (requestKey(name) !== key) return // a late response for a superseded request is dropped
433
493
  if (outcome.ok) {
434
494
  s.value = outcome.value
435
495
  s.at = Date.now()
@@ -451,11 +511,31 @@ export function createPanelCache(opts: DataOptions): PanelCache {
451
511
  if (!wanted.includes(name)) continue
452
512
  if (only && !only.has(name)) continue
453
513
  const s = state[name]
514
+ const key = requestKey(name)
515
+ if (key !== s.key) {
516
+ // The request key changed (page 5's cursor, the viewer's number): the cached value belongs
517
+ // to the old key, the child that is still running does too — kill it, drop the cache and
518
+ // rebuild against the new selection.
519
+ const old = blockChildren[name]
520
+ if (old) {
521
+ try {
522
+ old.kill('SIGKILL')
523
+ } catch {
524
+ /* already gone */
525
+ }
526
+ delete blockChildren[name]
527
+ }
528
+ s.key = key
529
+ s.value = undefined
530
+ s.at = 0
531
+ s.error = undefined
532
+ }
454
533
  const due = refreshOpts.force || s.at === 0 || now - s.at >= BLOCK_SPECS[name].ttlMs
455
534
  if (!due) continue
456
535
  if (inFlight[name]) continue
457
- inFlight[name] = build(name).finally(() => {
536
+ inFlight[name] = build(name, key).finally(() => {
458
537
  delete inFlight[name]
538
+ delete blockChildren[name]
459
539
  })
460
540
  }
461
541
  // Already-running builds count as this refresh's work: the caller wants a settled snapshot.