teamsmith 0.4.7 → 0.4.8

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 (42) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +11 -0
  4. package/skills/teamsmith/SKILL.md +12 -8
  5. package/skills/teamsmith/references/config.md +11 -12
  6. package/skills/teamsmith/scripts/lib/cmd-review.sh +21 -33
  7. package/skills/teamsmith/scripts/lib/common.sh +1 -1
  8. package/skills/teamsmith/scripts/panel/README.md +35 -33
  9. package/skills/teamsmith/scripts/panel/panel.js +217 -199
  10. package/skills/teamsmith/scripts/panel/src/App.tsx +221 -66
  11. package/skills/teamsmith/scripts/panel/src/layout.ts +139 -302
  12. package/skills/teamsmith/scripts/panel/src/project-settings.ts +46 -0
  13. package/skills/teamsmith/scripts/panel/src/strings/en.ts +71 -205
  14. package/skills/teamsmith/scripts/panel/src/strings/index.ts +3 -5
  15. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +72 -204
  16. package/skills/teamsmith/scripts/panel/src/types.ts +23 -4
  17. package/skills/teamsmith/scripts/strings/commands.tsv +1 -1
  18. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +7 -0
  19. package/skills/teamsmith/templates/pm-prompt.md.tmpl +10 -6
  20. package/skills/teamsmith/tests/help-surface.sh +75 -7
  21. package/skills/teamsmith/tests/install-shape.sh +7 -7
  22. package/skills/teamsmith/tests/key-replies-ui.sh +11 -5
  23. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +2 -0
  24. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +255 -90
  25. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +181 -61
  26. package/skills/teamsmith/tests/lib/model-routing-roles.sh +125 -67
  27. package/skills/teamsmith/tests/lib/reply-fixture.sh +14 -9
  28. package/skills/teamsmith/tests/lib/tmp-root.sh +1 -1
  29. package/skills/teamsmith/tests/loop-inventory.tsv +2 -0
  30. package/skills/teamsmith/tests/panel-b2.sh +91 -31
  31. package/skills/teamsmith/tests/panel-p21.sh +607 -1162
  32. package/skills/teamsmith/tests/panel-strings.mjs +21 -113
  33. package/skills/teamsmith/tests/remind-adversarial-faults.mjs +65 -38
  34. package/skills/teamsmith/tests/remind-adversarial-faults.sh +64 -12
  35. package/skills/teamsmith/tests/remind-adversarial-real.sh +13 -12
  36. package/skills/teamsmith/tests/remind-tool-real.mjs +159 -112
  37. package/skills/teamsmith/tests/remind-tool-real.sh +178 -3
  38. package/skills/teamsmith/tests/section-paths.tsv +10 -10
  39. package/skills/teamsmith/tests/smoke.sh +108 -114
  40. package/skills/teamsmith/tests/task-model-routing.sh +57 -26
  41. package/skills/teamsmith/tests/tmp-hygiene.sh +1 -1
  42. package/skills/teamsmith-init/SKILL.md +1 -1
@@ -19,6 +19,7 @@
19
19
  // one summary line when the height runs out → blocks collapse entirely, and the minimal tier drops
20
20
  // table columns / abbreviates states. Blocks whose source has no data collapse and yield the space.
21
21
 
22
+ import { MODEL_SETTINGS, CHECK_SETTINGS, COMMAND_SETTINGS, effectiveSetting, isSecondsSetting, settingTiming, settingsPageTitle, limitsTokens, limitFields, limitsValue, limitsDisplay } from './project-settings.js'
22
23
  import { fmtAge, fmtMB, GLYPH, clockOf, shortBranch, sparkline } from './format.js'
23
24
  import { markdownMemo } from './markdown.js'
24
25
  import { fill, keyLabel, OVERLAY_LABEL_W } from './strings/index.js'
@@ -37,7 +38,6 @@ import type {
37
38
  Frame,
38
39
  FrameInput,
39
40
  Hit,
40
- Impediment,
41
41
  LaneWindow,
42
42
  Line,
43
43
  PageId,
@@ -58,6 +58,8 @@ import type {
58
58
  SettingsKey,
59
59
  SettingsPmLaunch,
60
60
  SettingsWindow,
61
+ SettingsPage,
62
+ LimitsDraft,
61
63
  Tone,
62
64
  ViewState,
63
65
  } from './types.js'
@@ -1559,105 +1561,20 @@ function replySummaryBlock(ctx: Ctx): Block | null {
1559
1561
 
1560
1562
  // ------------------------------------------------------------------ project settings (P22/B2)
1561
1563
  //
1562
- // The view is a listing of the contract: one row per schema key plus one per key the file carries
1563
- // that the schema does not know, grouped by the functional domain the **command** reports on the
1564
- // row's `group` (P30 — the console owns no second table). Under the keys the view carries the two
1565
- // halves of the model policy the command reports (P232): the **future** policy's category rows
1566
- // (editable, one `set-task-model` per row) and the **committed** assignments plus the PM launch
1567
- // record (read-only). The two halves are rendered under separate headings and never merged: a
1568
- // future category model is never displayed as a seat's actual model.
1569
- //
1570
- // Rows, groups and classes come from the `settings` block's JSON at render time; a key added to the
1571
- // command's schema shows up without rebuilding `panel.js`. The list is windowed against the height
1572
- // the assembly hands over (the bounded-frame rule: more pane means more rows, never more blank).
1573
-
1574
- // The row's identity column is a **label** (M49), not the key name: the table's labels are human
1575
- // sentences, so the column only has to hold the longest of them (zh is the wide language here;
1576
- // a longer en label is cut by `cell()`, the same rule the key names followed).
1577
- const SETTINGS_LABEL_W = 22
1578
- /** P232: the policy migration diagnosis is shown above the audit tail; the rest is counted. */
1579
- const SETTINGS_DIAG_LINES = 2
1580
- /** P232: how many frame lines one diagnosis line may wrap to before it is cut with an ellipsis. */
1581
- const SETTINGS_DIAG_WRAP = 2
1582
- // The tail the block draws under its row window: the focused row's CLI hint and, when the command
1583
- // reports one, the policy migration diagnosis (P266: the audit tail is no longer drawn here — the
1584
- // log stays readable through `team config list`'s own footer and `team config log`, and the console
1585
- // is deliberately not one of its readers), plus `SETTINGS_COUNT_ROWS`, the pessimistic reservation
1586
- // for the two hidden-row counts (`↑n`/`↓n`). Reserving **both** counts is what keeps the block inside
1587
- // the frame once the list is longer than the window: with only the tail reserved, a full window
1588
- // plus a full tail overflowed and the whole view degraded to its one-line summary (measured in
1589
- // M55's pairlist route: the seats block the route had just focused disappeared from the frame).
1590
- //
1591
- // P32 (the user's second report, 2026-09-22): the reservation is a *ceiling*, not a fixed cost. The
1592
- // window spends what the tail does not need (a count line is only drawn when the window really
1593
- // hides rows at that edge), and the block pads its card to the lines it was handed — so the pane's
1594
- // height shows contract rows instead of the page's blank space.
1564
+ // Selected operations use the existing command read; navigation is local to this view.
1565
+ const SETTINGS_LABEL_W = 30
1595
1566
  const SETTINGS_COUNT_ROWS = 2
1596
-
1597
- /**
1598
- * The two pickers' *paged* list bound (M55's calibrated value, kept: a picker covers the row list, so
1599
- * this reservation is its own chrome — title + interval + the two hidden-count lines + blank + hint).
1600
- * A long vocabulary shows a `↑n`/`↓n` window that scrolls instead of flooding the pane, which is what
1601
- * the archived `choices` fixture calibrates its twenty-eight model records against. Their cards still
1602
- * fill (the pad below), so the key band stays the frame's last row.
1603
- */
1604
1567
  const SETTINGS_TAIL_ROWS = SETTINGS_COUNT_ROWS + 6
1605
-
1606
- /** One drawn row of the project-settings view (group headings are not focusable). */
1607
1568
  export type SettingsRow =
1608
1569
  | { kind: 'group'; label: string; tone: Tone }
1609
1570
  | { kind: 'key'; key: SettingsKey }
1610
1571
  | { kind: 'category'; category: SettingsCategory }
1611
1572
  | { kind: 'assignment'; assignment: SettingsAssignment }
1612
1573
  | { kind: 'pm-launch'; launch: SettingsPmLaunch }
1574
+ | { kind: 'nav'; page: 'commands' | 'records'; label: string }
1575
+ | { kind: 'info'; text: string }
1576
+ | { kind: 'rule'; action: 'select' | 'add' | 'save' | 'model' | 'count' | 'delete'; index: number; label: string; value: string }
1613
1577
 
1614
- export function settingsClassLabel(s: Strings, cls: string): string {
1615
- if (cls === 'restart') return s.settingsBadgeRestart
1616
- if (cls === 'refuse') return s.settingsBadgeRefuse
1617
- return s.settingsBadgeApply
1618
- }
1619
-
1620
- /**
1621
- * The effect class's tone (P30/D4): the *badge*'s tone, never the whole row's. `restart` is the one
1622
- * class that warns, `refuse` recedes, and `apply` stays the plain text tone — 48 of 111 rows would
1623
- * shout in green while the user's question is "does this need a restart?". Colour is never the only
1624
- * channel: the badge's word always carries the class (the panel's standing rule).
1625
- */
1626
- /**
1627
- * The declared marker the owning command puts at the start of a fixture-only key's note
1628
- * (`memory-and-deps` owns the marker). The hiding rule reads the read's data and nothing else: no
1629
- * key list is baked into the bundle, so a fixture key added to the schema stays hidden and one whose
1630
- * marker is removed comes back without rebuilding `panel.js`.
1631
- */
1632
- const SETTINGS_FIXTURE_ONLY_MARKER = 'fixture-only: '
1633
-
1634
- function settingsKeyHidden(k: SettingsKey): boolean {
1635
- return String(k.route ?? '').startsWith(SETTINGS_FIXTURE_ONLY_MARKER)
1636
- }
1637
-
1638
- function settingsClassTone(cls: string): Tone {
1639
- if (cls === 'restart') return 'warn'
1640
- if (cls === 'refuse') return 'dim'
1641
- return 'text'
1642
- }
1643
-
1644
- /**
1645
- * A functional group's heading label: `group_<token>` from the tables, falling back to the raw
1646
- * token when the table has none (a schema freshly edited against the committed bundle) — the same
1647
- * visible fallback `keyLabel` uses for an unknown key. Nothing here maps a key to a group.
1648
- */
1649
- function groupLabel(s: Strings, token: string): string {
1650
- const label = s[`group_${token}`]
1651
- return typeof label === 'string' && label.length > 0 ? label : token
1652
- }
1653
-
1654
- /**
1655
- * The CLI's own three source labels (the console invents no fourth state).
1656
- *
1657
- * The committed record's provenance: `selected_via`/`launch_via` are the CLI's own closed tokens
1658
- * (`explicit`/`policy`/`assignment`, plus the legacy spellings it still reports). The console only
1659
- * spells them; it never derives them.
1660
- */
1661
1578
  export function settingsSourceLabel(s: Strings, source: string): string {
1662
1579
  if (source === 'explicit') return s.seatSourceExplicit
1663
1580
  if (source === 'policy') return s.seatSourcePolicy
@@ -1666,117 +1583,82 @@ export function settingsSourceLabel(s: Strings, source: string): string {
1666
1583
  return source || s.dash
1667
1584
  }
1668
1585
 
1669
- /**
1670
- * The view's filtered row list: the contract's keys grouped by the **record's** `group` (P30/D1-D3),
1671
- * in the read's own order, then the future policy's category rows and the committed assignments.
1672
- * Pure and exported: the App walks exactly this list when it moves the focus, so the keys can never
1673
- * disagree with what is on screen.
1674
- *
1675
- * The bundle owns no key→group table and no group list: the walk opens a heading whenever the
1676
- * token changes, so a key (or a whole group) added to the command's schema appears under its
1677
- * reported heading with the committed bundle. Rows whose token is empty — a schema row that
1678
- * declares none, or a key the file carries and the schema does not know — are never dropped: they
1679
- * collect into one visible trailing fallback heading, before the categories block.
1680
- *
1681
- * P232: the categories block (the future policy) comes before the assignments block (the committed
1682
- * records), each with its own heading, so "what the next task will use" and "what is actually
1683
- * running" are never read as the same list. A seat with no complete record still gets a row that
1684
- * says so — it is never filled in from the policy above.
1685
- */
1686
- export function settingsViewRows(block: SettingsBlock | undefined, filter: string, s: Strings): SettingsRow[] {
1586
+ export function settingsViewRows(block: SettingsBlock | undefined, filter: string, s: Strings,
1587
+ page: SettingsPage = 'main', limits?: LimitsDraft | null, details?: string[] | null, detailWidth = 120): SettingsRow[] {
1588
+ if (details) return details.flatMap((line) => line.split('\n').flatMap((text) => diagnoseChunks(text, Math.max(1, detailWidth - 3), Infinity)).map((text) => ({ kind: 'info' as const, text })))
1687
1589
  const out: SettingsRow[] = []
1688
1590
  if (!block || !Array.isArray(block.keys)) return out
1689
- const needle = String(filter ?? '').trim().toLowerCase()
1690
- const match = (...parts: string[]): boolean =>
1691
- needle === '' || parts.some((p) => String(p ?? '').toLowerCase().includes(needle))
1692
- // The label first (what the row shows), then the raw key and the value — the three inputs a
1693
- // user may type into `/` (the label's words, `TEAM_…`, or the value on screen).
1694
- // P266: a key the read marks fixture-only is not a row at all — no row, no heading of its own and
1695
- // no `/` hit (it is dropped before the match, so not even its label or raw name can reach it).
1696
- const shown = block.keys.filter(
1697
- (k) =>
1698
- !settingsKeyHidden(k) &&
1699
- match(keyLabel(s, k.name), k.name, k.value, k.default, k.comment, k.warning, k.route ?? ''),
1700
- )
1701
- const ungrouped: SettingsKey[] = []
1702
- let openToken: string | null = null
1703
- for (const k of shown) {
1704
- const token = String(k.group ?? '')
1705
- if (!token) {
1706
- ungrouped.push(k)
1707
- continue
1708
- }
1709
- if (token !== openToken) {
1710
- out.push({ kind: 'group', label: groupLabel(s, token), tone: 'heading' })
1711
- openToken = token
1591
+ const needle = filter.trim().toLowerCase()
1592
+ const match = (...parts: string[]): boolean => !needle || parts.some((p) => String(p ?? '').toLowerCase().includes(needle))
1593
+ const keys = (names: readonly string[]): SettingsRow[] => names.flatMap((name) => {
1594
+ const key = block.keys.find((k) => k.name === name)
1595
+ return key && match(keyLabel(s, name), name, effectiveSetting(key)) ? [{ kind: 'key' as const, key }] : []
1596
+ })
1597
+ const group = (label: string, rows: SettingsRow[]): void => {
1598
+ if (rows.length) out.push({ kind: 'group', label, tone: 'heading' }, ...rows)
1599
+ }
1600
+ if ((page === 'limits' || page === 'rule') && limits) {
1601
+ if (limits.confirm) {
1602
+ out.push({ kind: 'group', label: s.settingsOld, tone: 'heading' },
1603
+ ...limitsDisplay(limits.original, s).flatMap((text) => diagnoseChunks(text, Math.max(1, detailWidth - 3), Infinity)).map((text) => ({ kind: 'info' as const, text })),
1604
+ { kind: 'group', label: s.settingsNew, tone: 'heading' },
1605
+ ...limitsDisplay(limitsValue(limits), s).flatMap((text) => diagnoseChunks(text, Math.max(1, detailWidth - 3), Infinity)).map((text) => ({ kind: 'info' as const, text })),
1606
+ { kind: 'rule', action: 'save', index: 0, label: s.settingsSave, value: '' })
1607
+ } else if (page === 'rule') {
1608
+ const [model, count] = limitFields(limits.tokens[limits.rule])
1609
+ out.push(
1610
+ { kind: 'rule', action: 'model', index: limits.rule, label: s.settingsRuleModel, value: model },
1611
+ { kind: 'rule', action: 'count', index: limits.rule, label: s.settingsRuleCount, value: count === '0' ? s.settingsRuleUnlimited : count },
1612
+ { kind: 'rule', action: 'delete', index: limits.rule, label: s.settingsRuleDelete, value: '' })
1613
+ } else {
1614
+ limits.tokens.forEach((token, index) => {
1615
+ const [model, count] = limitFields(token)
1616
+ out.push({ kind: 'rule', action: 'select', index, label: model, value: count === '0' ? s.settingsRuleUnlimited : count })
1617
+ })
1618
+ out.push({ kind: 'rule', action: 'add', index: 0, label: s.settingsRuleAdd, value: '' },
1619
+ { kind: 'rule', action: 'save', index: 0, label: s.settingsSave, value: '' })
1712
1620
  }
1713
- out.push({ kind: 'key', key: k })
1714
- }
1715
- if (ungrouped.length) {
1716
- out.push({ kind: 'group', label: s.settingsGroupUngrouped, tone: 'heading' })
1717
- for (const k of ungrouped) out.push({ kind: 'key', key: k })
1718
- }
1719
- const categories = (block.models?.policy?.categories ?? []).filter((c) =>
1720
- match(fill(s.settingsCategoryRow, { category: c.category }), c.category, c.model),
1721
- )
1722
- if (categories.length) {
1723
- out.push({ kind: 'group', label: s.settingsGroupCategories, tone: 'heading' })
1724
- for (const c of categories) out.push({ kind: 'category', category: c })
1725
- }
1726
- // P266: the command's diagnostic is deliberately not searchable here — it never reaches the
1727
- // screen, so `/` must not find a row for a string the user cannot see anywhere.
1728
- const assignments = (block.models?.assignments ?? []).filter((a) =>
1729
- match(a.agent, a.task, a.category, a.model, a.sid, a.selected_via, a.launch_via),
1730
- )
1731
- const launch = block.models?.pm_launch ?? {}
1732
- const launchShown =
1733
- Object.keys(launch).length > 0 &&
1734
- match(s.settingsPmLaunchLabel, String(launch.model ?? ''), String(launch.mode ?? ''), String(launch.window ?? ''))
1735
- if (assignments.length || launchShown) {
1736
- out.push({ kind: 'group', label: s.settingsGroupAssignments, tone: 'heading' })
1737
- for (const a of assignments) out.push({ kind: 'assignment', assignment: a })
1738
- if (launchShown) out.push({ kind: 'pm-launch', launch })
1621
+ return out
1739
1622
  }
1623
+ if (page === 'records') {
1624
+ for (const assignment of block.models?.assignments ?? []) {
1625
+ if (match(assignment.agent, assignment.task, assignment.category, assignment.model, assignment.sid, assignment.selected_via, assignment.launch_via))
1626
+ out.push({ kind: 'assignment', assignment })
1627
+ }
1628
+ const launch = block.models?.pm_launch ?? {}
1629
+ if (Object.keys(launch).length && match(s.settingsPmLaunchLabel, ...Object.values(launch))) out.push({ kind: 'pm-launch', launch })
1630
+ } else if (page === 'commands') {
1631
+ out.push(...keys(COMMAND_SETTINGS))
1632
+ } else {
1633
+ group(s.settingsGroupCategories, [
1634
+ ...(block.models?.policy?.categories ?? []).filter((c) => match(c.category, c.model)).map((category) => ({ kind: 'category' as const, category })),
1635
+ ...keys(MODEL_SETTINGS)])
1636
+ group(s.settingsChecks, keys(CHECK_SETTINGS))
1637
+ for (const [page, label] of [['commands', s.settingsCommands], ['records', s.settingsRecords]] as const)
1638
+ if (match(label)) out.push({ kind: 'nav', page, label })
1639
+ }
1640
+ // Errors are independent of filtering: hiding keys must not hide genuine diagnostics.
1641
+ const errors = [...String(block.models?.diagnostic ?? '').split('\n').filter(Boolean),
1642
+ ...block.keys.filter((k) => k.warning).map((k) => [k.warning, k.route].filter(Boolean).join('\n'))]
1643
+ if (errors.length) out.push({ kind: 'group', label: s.settingsDiagnosisHeading, tone: 'warn' })
1644
+ for (const text of errors) out.push({ kind: 'info', text })
1740
1645
  return out
1741
1646
  }
1742
-
1743
- /** True for the rows the focus walk may stop on (headings are not focusable). */
1744
1647
  export function settingsRowFocusable(row: SettingsRow): row is Exclude<SettingsRow, { kind: 'group' }> {
1745
1648
  return row.kind !== 'group'
1746
1649
  }
1747
-
1748
- /**
1749
- * The badge + value column shared by a key row and a seat row. The class tone covers the **badge
1750
- * only** (P30/D4): the value beside it stays in the plain text tone, because a class meaning is
1751
- * not a property of the value. A row with no badge (the seats) keeps its single-tone right column.
1752
- */
1753
1650
  function settingsRight(ctx: Ctx, text: string, badge: string, tone: Tone, innerW: number): Line {
1754
- const shown = truncateW(text, Math.max(6, innerW - SETTINGS_LABEL_W - 14))
1755
- return badge === '' ? ln(seg(` ${shown}`, tone)) : ln(seg(` ${shown} · `, 'text'), seg(badge, tone))
1651
+ return ln(seg(' ' + truncateW(text, Math.max(6, innerW - Math.min(SETTINGS_LABEL_W, Math.floor(innerW / 2)) - 4)), tone))
1756
1652
  }
1757
-
1758
1653
  function settingsKeyLine(ctx: Ctx, row: SettingsKey, focused: boolean, innerW: number): PlacedLine {
1759
- const { s } = ctx
1760
- const known = row.known !== false
1761
- const valueText =
1762
- row.set || row.value !== ''
1763
- ? row.value === ''
1764
- ? '\"\"'
1765
- : row.value
1766
- : fill(s.settingsUnset, { value: row.default || s.dash })
1767
- const badge = known ? settingsClassLabel(s, row.class) : s.settingsUnknownBadge
1768
- const tone: Tone = known ? settingsClassTone(row.class) : 'dim'
1769
- const line = ln(
1770
- seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1771
- // The row's main text is the human label; the raw key is not repeated here (it stays in the
1772
- // editor's title, the confirmation line and the view's CLI hint — the places where the user
1773
- // types the key into `team config set`). An unknown key has no label → its raw name (M49).
1774
- seg(cell(keyLabel(s, row.name), SETTINGS_LABEL_W), focused ? 'selected' : known ? 'heading' : 'dim'),
1775
- ...settingsRight(ctx, valueText, badge, tone, innerW).map((x) => x),
1776
- )
1777
- const note = (row.warning || row.route || row.comment || '').trim()
1778
- if (note) line.push(seg(` ${truncateW(note, Math.max(8, innerW - dispWidth(textOf(line)) - 2))}`, row.warning ? 'warn' : row.route && !known ? 'warn' : 'dim'))
1779
- return { line }
1654
+ const value = effectiveSetting(row)
1655
+ const summary = row.name === 'TEAM_MODEL_LIMITS' && limitsTokens(value) !== null
1656
+ ? fill(ctx.s.settingsEntries, { n: String(limitsTokens(value)!.length) })
1657
+ : row.kind === 'bool' && (value === '0' || value === '1') ? value === '1' ? ctx.s.settingsBoolOn : ctx.s.settingsBoolOff
1658
+ : value ? isSecondsSetting(row.name) ? `${value} ${ctx.s.settingsSeconds}` : value : ctx.s.settingsUnfilled
1659
+ return { line: ln(seg(`${focused ? ctx.s.settingsCursor : ' '} `, 'accent'),
1660
+ seg(cell(keyLabel(ctx.s, row.name), Math.min(SETTINGS_LABEL_W, Math.floor(innerW / 2))), focused ? 'selected' : 'heading'),
1661
+ ...settingsRight(ctx, summary, '', 'text', innerW)) }
1780
1662
  }
1781
1663
 
1782
1664
  /**
@@ -1839,70 +1721,45 @@ function diagnoseChunks(text: string, width: number, maxLines: number): string[]
1839
1721
  /**
1840
1722
  * One future-policy category row (P232). The category token is the row's identity (the project
1841
1723
  * defines it; there is no table entry for a project's own vocabulary), the value is the model the
1842
- * next new task of that category will get, and the badge says "new tasks" so the row cannot be
1843
- * read as a running seat. The command line under the list names the one write it offers.
1724
+ * next new task of that category will get. Only the selected operation adds its new-task timing.
1844
1725
  */
1845
1726
  function settingsCategoryLine(ctx: Ctx, cat: SettingsCategory, focused: boolean, innerW: number): PlacedLine {
1846
1727
  const { s } = ctx
1847
1728
  const line = ln(
1848
1729
  seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1849
- seg(cell(fill(s.settingsCategoryRow, { category: cat.category }), SETTINGS_LABEL_W), focused ? 'selected' : 'heading'),
1850
- ...settingsRight(ctx, cat.model || s.dash, s.settingsCategoryBadge, 'text', innerW).map((x) => x),
1730
+ seg(cell(fill(s.settingsCategoryRow, { category: cat.category }), Math.min(SETTINGS_LABEL_W, Math.floor(innerW / 2))), focused ? 'selected' : 'heading'),
1731
+ ...settingsRight(ctx, cat.model || s.dash, '', 'text', innerW).map((x) => x),
1851
1732
  )
1852
1733
  return { line }
1853
1734
  }
1854
1735
 
1855
1736
  /**
1856
- * One read-only committed assignment row (P232): the seat, its actual model, the origin tokens the
1857
- * CLI recorded and — on the note — the task, category and SID. `assigned=false` shows the command's
1858
- * own diagnostic instead of inventing a model from the policy above.
1737
+ * Read-only dispatch facts. Missing and unreadable records remain distinct; the full model,
1738
+ * task, category, session and source fields are available in the selected details.
1859
1739
  */
1740
+ export function settingsRecordDetails(row: Extract<SettingsRow, {kind: 'assignment' | 'pm-launch'}>, s: Strings): string[] {
1741
+ if (row.kind === 'assignment') {
1742
+ const a = row.assignment
1743
+ if (!a.assigned) return [a.record_present === false ? s.settingsAssignmentNone : s.settingsAssignmentUnreadable]
1744
+ return [
1745
+ [s.settingsRecordTask, a.task], [s.settingsRecordCategory, a.category], [s.settingsRecordModel, a.model],
1746
+ [s.settingsRecordSid, a.sid], [s.settingsRecordSelected, settingsSourceLabel(s, a.selected_via)],
1747
+ [s.settingsRecordLaunch, settingsSourceLabel(s, a.launch_via)],
1748
+ ].map(([label, value]) => label + ': ' + (value || s.dash))
1749
+ }
1750
+ return [[s.settingsRecordModel, row.launch.model], [s.settingsRecordTime, row.launch.time],
1751
+ [s.settingsRecordMode, row.launch.mode === 'fresh' ? s.settingsLaunchFresh : row.launch.mode === 'continued' ? s.settingsLaunchContinued : row.launch.mode], [s.settingsRecordWindow, row.launch.window]].filter(([, value]) => value).map(([label, value]) => label + ': ' + value)
1752
+ }
1860
1753
  function settingsAssignmentLine(ctx: Ctx, a: SettingsAssignment, focused: boolean, innerW: number): PlacedLine {
1861
1754
  const { s } = ctx
1862
- const line = ln(
1863
- seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1864
- seg(cell(a.agent, SETTINGS_LABEL_W), focused ? 'selected' : 'heading'),
1865
- ...settingsRight(
1866
- ctx,
1867
- a.assigned ? a.model || s.dash : s.dash,
1868
- s.settingsReadOnlyBadge,
1869
- 'dim',
1870
- innerW,
1871
- ).map((x) => x),
1872
- )
1873
- // P266: the command's diagnostic string never reaches the screen. The two plain reasons are chosen
1874
- // from the read's own fact (`record_present`): no record file at all vs. a record that exists but
1875
- // cannot be read — a seat that was used is never told it never was.
1876
- const note = a.assigned
1877
- ? fill(s.settingsAssignmentNote, {
1878
- task: a.task || s.dash,
1879
- category: a.category || s.dash,
1880
- sid: a.sid || s.dash,
1881
- selected: settingsSourceLabel(s, a.selected_via),
1882
- launch: settingsSourceLabel(s, a.launch_via),
1883
- })
1884
- : a.record_present === false
1885
- ? s.settingsAssignmentNone
1886
- : s.settingsAssignmentUnreadable
1887
- line.push(seg(` ${truncateW(note, Math.max(8, innerW - dispWidth(textOf(line)) - 2))}`, a.assigned ? 'dim' : 'warn'))
1888
- return { line }
1755
+ return { line: ln(seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1756
+ seg(a.agent + ' ', focused ? 'selected' : 'heading'),
1757
+ seg(a.assigned ? a.task + ' ' : '', 'text'),
1758
+ seg(a.assigned ? a.model || s.dash : a.record_present === false ? s.settingsAssignmentNone : s.settingsAssignmentUnreadable, 'text')) }
1889
1759
  }
1890
-
1891
- /** The PM's own last launch record, read-only — never a worker seat and never a policy row. */
1892
1760
  function settingsPmLaunchLine(ctx: Ctx, launch: SettingsPmLaunch, focused: boolean, innerW: number): PlacedLine {
1893
- const { s } = ctx
1894
- const line = ln(
1895
- seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1896
- seg(cell(s.settingsPmLaunchLabel, SETTINGS_LABEL_W), focused ? 'selected' : 'heading'),
1897
- ...settingsRight(ctx, launch.model || s.dash, s.settingsReadOnlyBadge, 'dim', innerW).map((x) => x),
1898
- )
1899
- const note = fill(s.settingsPmLaunchNote, {
1900
- window: launch.window || s.dash,
1901
- mode: launch.mode || s.dash,
1902
- time: launch.time || s.dash,
1903
- })
1904
- line.push(seg(` ${truncateW(note, Math.max(8, innerW - dispWidth(textOf(line)) - 2))}`, 'dim'))
1905
- return { line }
1761
+ return { line: ln(seg(`${focused ? ctx.s.settingsCursor : ' '} `, 'accent'),
1762
+ seg(ctx.s.settingsPmLaunchLabel + ' ', focused ? 'selected' : 'heading'), seg(launch.model || ctx.s.dash, 'text')) }
1906
1763
  }
1907
1764
 
1908
1765
  /**
@@ -1914,19 +1771,12 @@ function settingsPmLaunchLine(ctx: Ctx, launch: SettingsPmLaunch, focused: boole
1914
1771
  * '' when nothing is focusable.
1915
1772
  */
1916
1773
  function settingsCliHint(s: Strings, rows: SettingsRow[], focus: number): string {
1917
- const focusable = rows.filter(settingsRowFocusable)
1918
- const row = focusable[focus]
1919
- if (!row) return ''
1920
- if (row.kind === 'category') return fill(s.settingsCategoryHint, { category: row.category.category })
1921
- if (row.kind === 'assignment') return s.settingsAssignmentHint
1922
- if (row.kind === 'pm-launch') return s.settingsPmLaunchHint
1923
- const key = row.key
1924
- if (key.known === false) return fill(s.settingsUnknownHint, { key: key.name })
1925
- if (key.class === 'refuse') return s.settingsRefusedHint
1926
- // The whole-map row is not composed here: its editor is the categories block, and the command
1927
- // line the requirement names is the per-category one (P232).
1928
- if (String(key.kind ?? '') === 'task-model-map') return s.settingsCategoryMapHint
1929
- return fill(s.settingsCliHint, { key: key.name })
1774
+ const row = rows.filter(settingsRowFocusable)[focus]
1775
+ if (row?.kind === 'category') return s.settingsNewTasks
1776
+ if (row?.kind !== 'key') return ''
1777
+ if (row.key.class === 'refuse') return row.key.route || row.key.warning || s.settingsRefusedRoute
1778
+ if (row.key.name === 'TEAM_PULSE_MAX_RESTARTS' && effectiveSetting(row.key) === '0') return s.settingsNoRecovery
1779
+ return settingTiming(s, row.key.name)
1930
1780
  }
1931
1781
 
1932
1782
  /**
@@ -1944,7 +1794,7 @@ function settingsBlock(ctx: Ctx): Block | null {
1944
1794
  full: true,
1945
1795
  priority: 1,
1946
1796
  separator: 'none',
1947
- title: s.settingsViewTitle,
1797
+ title: settingsPageTitle(s, ctx.view.settingsPage ?? 'main'),
1948
1798
  lines,
1949
1799
  settings,
1950
1800
  summary: { line: truncLine(ln(seg(` ${s.settingsViewTitle}`, 'heading')), ctx.width) },
@@ -1959,7 +1809,7 @@ function settingsBlock(ctx: Ctx): Block | null {
1959
1809
  ),
1960
1810
  ])
1961
1811
  }
1962
- const rows = settingsViewRows(block, ctx.view.settingsFilter ?? '', s)
1812
+ const rows = settingsViewRows(block, ctx.view.settingsFilter ?? '', s, ctx.view.settingsPage, ctx.view.limitsDraft, ctx.view.settingsDetails, width)
1963
1813
  let count = 0
1964
1814
  for (const r of rows) if (settingsRowFocusable(r)) count += 1
1965
1815
  // P32: the block's budget is the **lines** it may draw below the card frame — the assembly hands
@@ -1971,17 +1821,12 @@ function settingsBlock(ctx: Ctx): Block | null {
1971
1821
  const explicitOffset = ctx.view.settingsOffset
1972
1822
  // P232: the command's own policy diagnosis (missing/retired keys, an unmapped category map) is
1973
1823
  // part of the view: a legacy contract must say so, with the CLI route the command itself names.
1974
- const diagnosis = String(block.models?.diagnostic ?? '')
1975
- .split('\n')
1976
- .map((l) => l.trim())
1977
- .filter((l) => l !== '')
1978
- const diagShown = diagnosis.slice(0, SETTINGS_DIAG_LINES)
1979
- const diagRest = diagnosis.length - diagShown.length
1980
- const diagChunks = diagShown.map((d) => diagnoseChunks(d, Math.max(8, width - 3), SETTINGS_DIAG_WRAP))
1981
- const diagLines = diagChunks.length ? diagChunks.reduce((n, c) => n + c.length, 0) + 1 + (diagRest > 0 ? 1 : 0) : 0
1982
- // P266: the tail is the focused row's CLI hint plus the diagnosis when there is one; the audit
1983
- // tail that used to sit here is no longer drawn (and no longer reads the log).
1984
- const tailLines = 1 + diagLines
1824
+ const focusedRow = rows.filter(settingsRowFocusable)[focus]
1825
+ const selectedHint = focusedRow?.kind === 'assignment' || focusedRow?.kind === 'pm-launch'
1826
+ ? settingsRecordDetails(focusedRow, s).join('\n') : settingsCliHint(s, rows, focus)
1827
+ const hintLines = selectedHint.split('\n').filter(Boolean).flatMap((text) => diagnoseChunks(text, Math.max(8, width - 3), Infinity))
1828
+ const shownHint = hintLines.slice(0, Math.max(0, room - 5))
1829
+ const tailLines = shownHint.length
1985
1830
  // The row cap: each row costs at least its own line, and the tail is already spoken for.
1986
1831
  const desired = Math.max(1, Math.min(Math.max(1, count), Math.max(1, room - tailLines)))
1987
1832
  const maxOffset = Math.max(0, count - desired)
@@ -2077,16 +1922,16 @@ function settingsBlock(ctx: Ctx): Block | null {
2077
1922
  const entryLabel = (e: SettingsChoiceEntry): string => {
2078
1923
  const base =
2079
1924
  e.kind === 'keep-unset'
2080
- ? s.settingsChoiceKeepUnset
1925
+ ? choice.entries.some((entry) => entry.kind === 'default') ? s.settingsChoiceKeepUnset : s.settingsKeepEmpty
2081
1926
  : e.kind === 'clear'
2082
1927
  ? s.settingsChoiceClear
2083
1928
  : e.kind === 'free'
2084
- ? s.settingsChoiceFree
1929
+ ? choice.ruleField ? s.settingsRuleOther : s.settingsChoiceFree
2085
1930
  : choice.kind === 'bool' && (e.value === '1' || e.value === '0')
2086
1931
  ? e.value === '1'
2087
1932
  ? s.settingsBoolOn
2088
1933
  : s.settingsBoolOff
2089
- : e.value
1934
+ : isSecondsSetting(choice.key) ? `${e.value} ${s.settingsSeconds}` : e.value
2090
1935
  const marks: string[] = []
2091
1936
  if (e.kind === 'current') marks.push(s.settingsChoiceCurrent)
2092
1937
  if (e.kind === 'default') marks.push(s.settingsChoiceDefault)
@@ -2095,22 +1940,11 @@ function settingsBlock(ctx: Ctx): Block | null {
2095
1940
  }
2096
1941
  return marks.length ? `${base} · ${marks.join(' · ')}` : base
2097
1942
  }
2098
- put(
2099
- ln(
2100
- seg(
2101
- choice.category
2102
- ? ` ${fill(s.settingsCategoryPickerTitle, { category: choice.key })}`
2103
- : ` ${fill(s.settingsChoiceTitle, { label: keyLabel(s, choice.key), key: choice.key })}`,
2104
- 'heading',
2105
- ),
2106
- ),
2107
- )
2108
- if (choice.category) put(ln(seg(` ${s.settingsCategoryPickerHint}`, 'dim')))
2109
1943
  if (choice.interval) {
2110
1944
  put(
2111
1945
  ln(
2112
1946
  seg(
2113
- ` ${fill(s.settingsChoiceInterval, { min: choice.interval.min || '0', max: choice.interval.max || '∞' })}`,
1947
+ ` ${fill(s.settingsChoiceInterval, { min: choice.interval.min || '0', max: choice.interval.max || '∞' })}${isSecondsSetting(choice.key) ? ' ' + s.settingsSeconds : ''}`,
2114
1948
  'dim',
2115
1949
  ),
2116
1950
  ),
@@ -2135,7 +1969,7 @@ function settingsBlock(ctx: Ctx): Block | null {
2135
1969
  // P32: a picker covers the row list, so what its own entries do not use stays inside the card
2136
1970
  // (the fill rule below); a short picker must not leave the pane half blank either.
2137
1971
  while (lines.length < room) put(ln(seg('')))
2138
- return one(lines, { focus: sel, offset: entryOffset, visible: entryVisible, count: entries.length })
1972
+ return { ...one(lines, { focus: sel, offset: entryOffset, visible: entryVisible, count: entries.length, width }), title: choice.ruleField ? s.settingsRuleModel : choice.category ? choice.key : keyLabel(s, choice.key) }
2139
1973
  }
2140
1974
 
2141
1975
  const lines: PlacedLine[] = []
@@ -2159,7 +1993,10 @@ function settingsBlock(ctx: Ctx): Block | null {
2159
1993
  ? settingsCategoryLine(ctx, r.category, focused, width)
2160
1994
  : r.kind === 'assignment'
2161
1995
  ? settingsAssignmentLine(ctx, r.assignment, focused, width)
2162
- : settingsPmLaunchLine(ctx, r.launch, focused, width)
1996
+ : r.kind === 'pm-launch' ? settingsPmLaunchLine(ctx, r.launch, focused, width)
1997
+ : { line: ln(seg(`${focused ? s.settingsCursor : ' '} `, 'accent'),
1998
+ seg(r.kind === 'info' ? r.text : r.label, focused ? 'selected' : 'text'),
1999
+ seg(r.kind === 'nav' ? ' ›' : r.kind === 'rule' && r.value ? ' ' + r.value : '', 'text')) }
2163
2000
  // The whole row is a target: a click on an unfocused row moves the focus, a second click on
2164
2001
  // the focused row opens it (the kanban's rule).
2165
2002
  const action: Action = focused ? { kind: 'settings-open', index: idx } : { kind: 'settings-focus', index: idx }
@@ -2175,14 +2012,7 @@ function settingsBlock(ctx: Ctx): Block | null {
2175
2012
  if (hiddenBelow > 0) put(ln(seg(` ${fill(s.laneHiddenBelow, { n: String(hiddenBelow) })}`, 'dim')))
2176
2013
 
2177
2014
  // The CLI-alignment line (M49): the row's label is for reading, the raw key is for typing.
2178
- put(ln(seg(` ${settingsCliHint(s, rows, focus)}`, 'dim')))
2179
-
2180
- // The policy's migration diagnosis (P232): visible, and the CLI route it names is the route.
2181
- if (diagShown.length) {
2182
- put(ln(seg(` ${s.settingsDiagnosisHeading}`, 'warn')))
2183
- for (const chunks of diagChunks) for (const d of chunks) put(ln(seg(` ${d}`, 'warn')))
2184
- if (diagRest > 0) put(ln(seg(` ${fill(s.laneHiddenBelow, { n: String(diagRest) })}`, 'dim')))
2185
- }
2015
+ for (const text of shownHint) put(ln(seg(` ${text}`, 'dim')))
2186
2016
 
2187
2017
  // P32 (the bounded-frame rule's last resort, the detail view's own): the space the rows did not
2188
2018
  // use stays **inside** the card, so the card fills the pane it was handed and the key band stays
@@ -2190,7 +2020,7 @@ function settingsBlock(ctx: Ctx): Block | null {
2190
2020
  // a short pane it is what the user read as "the view does not use the window's height".
2191
2021
  while (lines.length < room) put(ln(seg('')))
2192
2022
 
2193
- return one(lines, { focus, offset, visible, count })
2023
+ return one(lines, { focus, offset, visible, count, width })
2194
2024
  }
2195
2025
 
2196
2026
  /**
@@ -2362,7 +2192,7 @@ function decisionsBlock(ctx: Ctx): Block | null {
2362
2192
  // ------------------------------------------------------------------ body blocks (page 3)
2363
2193
 
2364
2194
  function queueBlock(ctx: Ctx): Block | null {
2365
- const { s, blocks, deg, width, view } = ctx
2195
+ const { s, panel, blocks, deg, width, view } = ctx
2366
2196
  const q = blocks.outbox_list
2367
2197
  if (!q && !deg.has('outbox_list')) return null
2368
2198
  if (deg.has('outbox_list') || !q) {
@@ -2385,10 +2215,11 @@ function queueBlock(ctx: Ctx): Block | null {
2385
2215
  }
2386
2216
  const lines: PlacedLine[] = []
2387
2217
  // delivery-truth D2:阻碍是**测量事实**(原因、观察时刻、诊断可否读),不是「有草稿」的暗示。
2388
- const imps: Impediment[] = q.impediments ?? []
2389
- if (q.impeded && q.impeded > 0) {
2218
+ const ob = panel.outbox
2219
+ if (!deg.has('outbox') && ob?.impeded && ob.impeded > 0) {
2220
+ const imps = ob.impediments ?? []
2390
2221
  const reasons = Array.from(new Set(imps.map((i) => i.reason))).join(' · ') || s.dash
2391
- lines.push({ line: truncLine(ln(seg(` ${fill(s.queueImpededLine, { n: q.impeded, reasons })}`, 'warn')), width) })
2222
+ lines.push({ line: truncLine(ln(seg(` ${fill(s.queueImpededLine, { n: ob.impeded, reasons })}`, 'warn')), width) })
2392
2223
  for (const im of imps.slice(0, 3)) {
2393
2224
  const when = im.diagnostic === 'available' && im.last_observed ? im.last_observed : s.queueImpededUnavailable
2394
2225
  lines.push({ line: truncLine(ln(seg(fill(s.queueImpededItem, { entry: im.entry, reason: im.reason, when }), 'warn')), width) })
@@ -2544,8 +2375,12 @@ function demotedPair(ctx: Ctx): { full: string; phase: string } | null {
2544
2375
  }
2545
2376
 
2546
2377
  function keyBandBlock(ctx: Ctx, rowsAvailable = true): Block {
2378
+ // The setting/filter editor already renders its own Enter/Esc hint. Keep no underlying targets.
2379
+ if (ctx.view.settings && ctx.view.settingsEditing) {
2380
+ return { id: 'keys', full: true, priority: 99, lines: [], separator: 'none' }
2381
+ }
2547
2382
  const { s, width } = ctx
2548
- const actions: { text: string; action: Action }[] = [
2383
+ const actions: { text: string; action: Action }[] = ctx.view.settings ? [] : [
2549
2384
  { text: s.keyCompose, action: { kind: 'compose' } },
2550
2385
  { text: s.keyFlush, action: { kind: 'flush' } },
2551
2386
  { text: s.keyStandby, action: { kind: 'standby' } },
@@ -2557,15 +2392,15 @@ function keyBandBlock(ctx: Ctx, rowsAvailable = true): Block {
2557
2392
  const nav: { text: string; action: Action }[] = ctx.view.settings
2558
2393
  ? ctx.view.choicePicker
2559
2394
  ? [
2395
+ { text: s.keySettingsBack, action: { kind: 'choice-close' } },
2560
2396
  { text: s.keyRows, action: { kind: 'choice-move', delta: 1 } },
2561
2397
  { text: s.keyOpen, action: { kind: 'choice-pick', index: -1 } },
2562
- { text: s.keyDetailClose, action: { kind: 'choice-close' } },
2563
2398
  ]
2564
2399
  : [
2400
+ { text: s.keySettingsBack, action: { kind: 'settings-close' } },
2565
2401
  { text: s.keyRows, action: { kind: 'settings-scroll', delta: 1 } },
2566
- { text: s.keyOpen, action: { kind: 'settings-open', index: -1 } },
2402
+ { text: settingsViewRows(ctx.blocks.settings, ctx.view.settingsFilter ?? '', s, ctx.view.settingsPage, ctx.view.limitsDraft, ctx.view.settingsDetails).filter(settingsRowFocusable)[ctx.view.settingsFocus ?? 0]?.kind === 'nav' ? s.keyOpen : s.keyCategoryPick, action: { kind: 'settings-open', index: -1 } },
2567
2403
  { text: s.keyFilter, action: { kind: 'settings-filter' } },
2568
- { text: s.keyDetailClose, action: { kind: 'settings-close' } },
2569
2404
  ]
2570
2405
  : ctx.view.detail
2571
2406
  ? [
@@ -2645,9 +2480,11 @@ function keyBandBlock(ctx: Ctx, rowsAvailable = true): Block {
2645
2480
  }
2646
2481
  push(item.text, item.action, chip, false)
2647
2482
  })
2648
- nav.forEach((item) => {
2649
- line.push(seg(' · ', 'dim'))
2650
- x += 3
2483
+ nav.forEach((item, i) => {
2484
+ if (actions.length || i > 0) {
2485
+ line.push(seg(' · ', 'dim'))
2486
+ x += 3
2487
+ }
2651
2488
  push(item.text, item.action, false, chip)
2652
2489
  })
2653
2490
  // P123: the focused card's demoted pair rides the free width the chips leave — right-aligned,