taskquoin 0.0.0-stage → 2026.12.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 (160) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/LICENSE +55 -0
  3. package/README.md +227 -2
  4. package/SECURITY.md +26 -0
  5. package/adapters/git/src/git.js +250 -0
  6. package/adapters/git/src/index.js +1 -0
  7. package/adapters/hooks-claude/src/canonical.js +45 -0
  8. package/adapters/hooks-claude/src/index.js +2 -0
  9. package/adapters/hooks-claude/src/main.js +58 -0
  10. package/adapters/hooks-claude/src/payload.js +40 -0
  11. package/adapters/host-probe/src/index.js +2 -0
  12. package/adapters/host-probe/src/ollama.js +18 -0
  13. package/adapters/host-probe/src/probe.js +107 -0
  14. package/adapters/local-tool/src/fingerprint.js +56 -0
  15. package/adapters/local-tool/src/index.js +4 -0
  16. package/adapters/local-tool/src/local-tool.js +22 -0
  17. package/adapters/local-tool/src/sandboxed.js +105 -0
  18. package/adapters/local-tool/src/scan.js +52 -0
  19. package/adapters/memory-claude-mem/src/claude-mem.js +115 -0
  20. package/adapters/memory-claude-mem/src/index.js +1 -0
  21. package/adapters/process-runner/src/index.js +1 -0
  22. package/adapters/process-runner/src/runner.js +123 -0
  23. package/adapters/runtime-api/src/capabilities.json +116 -0
  24. package/adapters/runtime-api/src/executor.js +131 -0
  25. package/adapters/runtime-api/src/index.js +1 -0
  26. package/adapters/runtime-claude/src/capabilities.json +375 -0
  27. package/adapters/runtime-claude/src/command.js +34 -0
  28. package/adapters/runtime-claude/src/executor.js +162 -0
  29. package/adapters/runtime-claude/src/index.js +4 -0
  30. package/adapters/runtime-claude/src/permissions.js +76 -0
  31. package/adapters/runtime-claude/src/stream.js +60 -0
  32. package/adapters/runtime-codex/src/capabilities.json +192 -0
  33. package/adapters/runtime-codex/src/command.js +36 -0
  34. package/adapters/runtime-codex/src/executor.js +83 -0
  35. package/adapters/runtime-codex/src/index.js +4 -0
  36. package/adapters/runtime-codex/src/scratch.js +32 -0
  37. package/adapters/runtime-codex/src/stream.js +39 -0
  38. package/adapters/runtime-opencode/src/capabilities.json +149 -0
  39. package/adapters/runtime-opencode/src/config.js +33 -0
  40. package/adapters/runtime-opencode/src/credentials.js +130 -0
  41. package/adapters/runtime-opencode/src/executor.js +127 -0
  42. package/adapters/runtime-opencode/src/facts.js +43 -0
  43. package/adapters/runtime-opencode/src/hosts.js +16 -0
  44. package/adapters/runtime-opencode/src/hosts.json +3 -0
  45. package/adapters/runtime-opencode/src/index.js +6 -0
  46. package/adapters/runtime-opencode/src/mounts.js +58 -0
  47. package/adapters/runtime-opencode/src/stream.js +63 -0
  48. package/adapters/skill-store/src/index.js +1 -0
  49. package/adapters/skill-store/src/skill-store.js +162 -0
  50. package/adapters/store-fs/src/index.js +2 -0
  51. package/adapters/store-fs/src/store.js +201 -0
  52. package/adapters/store-fs/src/trusted-dir.js +37 -0
  53. package/apps/cli/src/console.js +432 -0
  54. package/apps/cli/src/dashboard-approve.js +259 -0
  55. package/apps/cli/src/dashboard-data.js +424 -0
  56. package/apps/cli/src/dashboard.js +500 -0
  57. package/apps/cli/src/history.js +35 -0
  58. package/apps/cli/src/home.js +18 -0
  59. package/apps/cli/src/i18n/en.js +527 -0
  60. package/apps/cli/src/i18n/index.js +90 -0
  61. package/apps/cli/src/i18n/languages.js +25 -0
  62. package/apps/cli/src/i18n/locales/ar.json +526 -0
  63. package/apps/cli/src/i18n/locales/de.json +505 -0
  64. package/apps/cli/src/i18n/locales/es.json +505 -0
  65. package/apps/cli/src/i18n/locales/fa.json +505 -0
  66. package/apps/cli/src/i18n/locales/fr.json +505 -0
  67. package/apps/cli/src/i18n/locales/he.json +505 -0
  68. package/apps/cli/src/i18n/locales/hi.json +505 -0
  69. package/apps/cli/src/i18n/locales/id.json +491 -0
  70. package/apps/cli/src/i18n/locales/it.json +505 -0
  71. package/apps/cli/src/i18n/locales/ja.json +491 -0
  72. package/apps/cli/src/i18n/locales/ko.json +491 -0
  73. package/apps/cli/src/i18n/locales/nl.json +505 -0
  74. package/apps/cli/src/i18n/locales/pl.json +512 -0
  75. package/apps/cli/src/i18n/locales/pt-BR.json +505 -0
  76. package/apps/cli/src/i18n/locales/ru.json +512 -0
  77. package/apps/cli/src/i18n/locales/th.json +491 -0
  78. package/apps/cli/src/i18n/locales/tr.json +505 -0
  79. package/apps/cli/src/i18n/locales/uk.json +512 -0
  80. package/apps/cli/src/i18n/locales/vi.json +491 -0
  81. package/apps/cli/src/i18n/locales/zh-CN.json +491 -0
  82. package/apps/cli/src/i18n/locales/zh-TW.json +491 -0
  83. package/apps/cli/src/i18n/width.js +40 -0
  84. package/apps/cli/src/layout.js +18 -0
  85. package/apps/cli/src/main.js +830 -0
  86. package/apps/cli/src/preferences.js +46 -0
  87. package/apps/cli/src/runtime-notices.js +41 -0
  88. package/apps/cli/src/safe-text.js +3 -0
  89. package/apps/cli/src/shortcut.js +82 -0
  90. package/apps/cli/src/skills-cli.js +112 -0
  91. package/apps/cli/src/tui/caps.js +31 -0
  92. package/apps/cli/src/tui/components/agent-list.js +58 -0
  93. package/apps/cli/src/tui/components/approval-center.js +145 -0
  94. package/apps/cli/src/tui/components/approval.js +95 -0
  95. package/apps/cli/src/tui/components/dashboard-frame.js +293 -0
  96. package/apps/cli/src/tui/components/diff-viewer.js +549 -0
  97. package/apps/cli/src/tui/components/event-viewer.js +46 -0
  98. package/apps/cli/src/tui/components/help-panel.js +59 -0
  99. package/apps/cli/src/tui/components/home.js +185 -0
  100. package/apps/cli/src/tui/components/logo.js +67 -0
  101. package/apps/cli/src/tui/components/panel.js +70 -0
  102. package/apps/cli/src/tui/components/status-bar.js +96 -0
  103. package/apps/cli/src/tui/components/timeline.js +120 -0
  104. package/apps/cli/src/tui/keys.js +139 -0
  105. package/apps/cli/src/tui/neutral.js +68 -0
  106. package/apps/cli/src/tui/screen.js +111 -0
  107. package/apps/cli/src/tui/text.js +165 -0
  108. package/apps/cli/src/tui/tokens.js +89 -0
  109. package/apps/cli/src/tui/view.js +64 -0
  110. package/apps/cli/src/upgrade-check.js +86 -0
  111. package/apps/cli/src/upgrade-cli.js +168 -0
  112. package/apps/cli/src/workflow-cli.js +674 -0
  113. package/package.json +29 -4
  114. package/packages/application/src/index.js +8 -0
  115. package/packages/application/src/lib/digest.js +7 -0
  116. package/packages/application/src/ports/memory.js +1 -0
  117. package/packages/application/src/ports/runtime-executor.js +1 -0
  118. package/packages/application/src/projection/run-view.js +194 -0
  119. package/packages/application/src/projection/squad-view.js +33 -0
  120. package/packages/application/src/use-cases/prepare-run.js +68 -0
  121. package/packages/application/src/workflow/feature-governed.js +420 -0
  122. package/packages/application/src/workflow/gate-signals.js +40 -0
  123. package/packages/application/src/workflow/prompts.js +81 -0
  124. package/packages/config/src/config.js +372 -0
  125. package/packages/config/src/index.js +1 -0
  126. package/packages/domain/src/capabilities.js +13 -0
  127. package/packages/domain/src/capability-matrix.js +63 -0
  128. package/packages/domain/src/enforcement.js +95 -0
  129. package/packages/domain/src/index.js +4 -0
  130. package/packages/domain/src/policy.js +32 -0
  131. package/packages/rules/src/glob.js +47 -0
  132. package/packages/rules/src/index.js +5 -0
  133. package/packages/rules/src/inherit.js +19 -0
  134. package/packages/rules/src/lists.js +41 -0
  135. package/packages/rules/src/rules.js +79 -0
  136. package/packages/rules/src/shell.js +83 -0
  137. package/packages/skills/src/index.js +1 -0
  138. package/packages/skills/src/skills.js +108 -0
  139. package/skills/code-review/SKILL.md +51 -0
  140. package/skills/egm-design/LICENSE +202 -0
  141. package/skills/egm-design/SKILL.md +68 -0
  142. package/skills/egm-design/references/feature-spec-standard.md +39 -0
  143. package/skills/egm-implementation-readiness/LICENSE +202 -0
  144. package/skills/egm-implementation-readiness/SKILL.md +67 -0
  145. package/skills/egm-implementation-readiness/references/implementation-readiness-standard.md +37 -0
  146. package/skills/first-party.lock.json +10 -0
  147. package/skills/planning-contract/SKILL.md +51 -0
  148. package/skills/ponytail/LICENSE +21 -0
  149. package/skills/ponytail/SKILL.md +56 -0
  150. package/skills/security-review/SKILL.md +58 -0
  151. package/skills/tdd/SKILL.md +52 -0
  152. package/skills/unslop/LICENSE +396 -0
  153. package/skills/unslop/SKILL.md +239 -0
  154. package/skills/unslop/references/cjk.md +34 -0
  155. package/skills/unslop/references/effects.md +113 -0
  156. package/skills/unslop/references/refs.md +17 -0
  157. package/skills/unslop/references/rtl.md +111 -0
  158. package/skills/unslop/references/signs.md +122 -0
  159. package/skills/unslop/references/tokens.md +139 -0
  160. package/skills/unslop/references/visuals.md +84 -0
@@ -0,0 +1,293 @@
1
+ import { t, tn } from "../../i18n/index.js";
2
+ import { displayWidth } from "../../i18n/width.js";
3
+ import { n } from "../neutral.js";
4
+ import { bold, ellipsis, glyph, mark, paint, selected as selectedBg, stateToken } from "../tokens.js";
5
+ import { clip, clock, cut, localWhen, pad, wrap } from "../text.js";
6
+ import { renderAgents } from "./agent-list.js";
7
+ import { agentRows } from "../../dashboard-data.js";
8
+ import { renderEvents } from "./event-viewer.js";
9
+ import { panel, section } from "./panel.js";
10
+ import { renderHelp } from "./help-panel.js";
11
+ import { renderViewer } from "./diff-viewer.js";
12
+ import { renderFooter, renderTopBar, runState, statusWord } from "./status-bar.js";
13
+ import { renderTimeline } from "./timeline.js";
14
+ export const initialUi = () => ({ screen: 'main', focus: 'pipeline', tab: 'runs', pos: { pipeline: 0, approvals: 0, runs: 0, agents: 0, events: 0 }, help: false });
15
+ export function layoutMode(caps) {
16
+ if (caps.plain || !caps.interactive || caps.columns < 40 || caps.rows < 12)
17
+ return 'too-small';
18
+ if (caps.columns >= 120 && caps.rows >= 30)
19
+ return 'wide';
20
+ return caps.columns >= 80 ? 'stacked' : 'narrow';
21
+ }
22
+ const NBSP = ' ';
23
+ const FOOTER_KEYS = () => [
24
+ ['r', t('dashboard.frame.key.runs')], ['a', t('dashboard.frame.key.agents')], ['d', t('dashboard.frame.key.diff')], ['l', t('dashboard.frame.key.log')],
25
+ ['v', t('dashboard.frame.key.verify')], ['p', t('dashboard.frame.key.approvals')], ['?', t('dashboard.frame.key.help')], ['q', t('dashboard.frame.key.quit')],
26
+ ];
27
+ const TITLE = {
28
+ pipeline: () => t('dashboard.frame.pipeline'), approvals: () => t('dashboard.frame.approvals'), runs: () => t('dashboard.frame.runs'),
29
+ agents: () => t('dashboard.frame.agents'), events: () => t('dashboard.frame.events'),
30
+ };
31
+ const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
32
+ const shortOf = (m, sel) => m.runs.find((r) => r.runId === sel.runId)?.short ?? n(sel.runId.split('-').at(-1) ?? sel.runId);
33
+ // ---- Runs ---------------------------------------------------------------------------------------------------------
34
+ /** The Runs body: `▸` on the cursor row, glyph and word, short id, request, start time; the cursor stays in view. */
35
+ export function renderRuns(runs, o, caps, now) {
36
+ const { width, height } = o;
37
+ if (height <= 0)
38
+ return [];
39
+ if (runs.length === 0)
40
+ return [paint('muted', cut(t('dashboard.frame.noRuns'), width, ellipsis(caps)), caps)];
41
+ const cursor = clamp(o.cursor, 0, runs.length - 1);
42
+ const start = clamp(cursor - Math.floor(height / 2), 0, Math.max(0, runs.length - height));
43
+ return runs.slice(start, start + height).map((r, k) => {
44
+ const state = runState(r.status, r.liveness), word = statusWord(r.status, r.liveness);
45
+ const cur = start + k === cursor ? mark('cursor', caps) : ' ';
46
+ const when = localWhen(r.startedAt, now);
47
+ const headPlain = `${cur} ${glyph(state, caps)} ${n(r.short)} ${word}`;
48
+ const headW = displayWidth(headPlain);
49
+ const room = width - headW - 2 - displayWidth(when) - 2;
50
+ let line;
51
+ if (headW + 2 + displayWidth(when) > width)
52
+ line = cut(headPlain, width, ellipsis(caps));
53
+ else {
54
+ const head = `${cur} ${paint(stateToken(state), glyph(state, caps), caps)} ${n(r.short)} ${paint(stateToken(state), word, caps)}`;
55
+ const req = room >= 6 ? ` ${pad(cut(n(r.request), room, ellipsis(caps)), room)}` : '';
56
+ const gap = req === '' ? ' '.repeat(Math.max(1, width - headW - displayWidth(when))) : ' ';
57
+ line = head + req + gap + paint('muted', when, caps);
58
+ }
59
+ return r.runId === o.selected ? selectedBg(pad(clip(line, width), width), caps) : line;
60
+ });
61
+ }
62
+ // ---- Approvals ----------------------------------------------------------------------------------------------------
63
+ const GATE_STEP = { 'plan-approval': 'plan', 'commit-approval': 'commit' };
64
+ /** The first line of the Approvals body for a waiting gate: the hash is the last, unbroken, bold part. */
65
+ function waitingLine(view, width, caps) {
66
+ const gate = view.pending.gate;
67
+ const since = view.steps.find((s) => s.state === 'waiting')?.startedAt;
68
+ const hash = view.pending.binding.slice(0, 12);
69
+ const sep = ` ${mark('sep', caps)} `;
70
+ const head = `${glyph('waiting', caps)} ${t('dashboard.frame.waitingSince', { gate, time: clock(since) })}`;
71
+ const room = width - displayWidth(sep) - displayWidth(hash);
72
+ if (room < 4)
73
+ return cut(hash, width, '');
74
+ return paint('orange', cut(head, room, ellipsis(caps)), caps) + sep + bold(hash, caps);
75
+ }
76
+ /** The Approvals body (the human's next action for the selected run). Strings arrive neutral. */
77
+ export function renderApprovals(sel, waiting, width, caps, here = false) {
78
+ const more = ellipsis(caps);
79
+ if (!sel)
80
+ return [paint('muted', cut(t('dashboard.frame.none'), width, more), caps)];
81
+ const v = sel.view;
82
+ const status = v.status;
83
+ const state = runState(status, sel.liveness), word = statusWord(status, sel.liveness);
84
+ if (v.pending) {
85
+ const how = here ? t('dashboard.frame.openCenter') : t('dashboard.frame.approveHint', { gate: v.pending.gate });
86
+ return [waitingLine(v, width, caps), cut(`${mark('arrow', caps)} ${how}`, width, more)];
87
+ }
88
+ if (status === 'failed' || status === 'needs-human' || status === 'interrupted') {
89
+ const head = paint(stateToken(state), `${glyph(state, caps)} ${word}`, caps);
90
+ const reason = v.reason ? `: ${n(v.reason)}` : '';
91
+ const lines = [head + cut(reason, Math.max(0, width - displayWidth(`${glyph(state, caps)} ${word}`)), more)];
92
+ if (status === 'interrupted')
93
+ lines.push(cut(t('dashboard.frame.resume', { run: n(v.runId) }), width, more));
94
+ return lines;
95
+ }
96
+ if (status === 'running' && sel.liveness !== 'live') {
97
+ return [`${paint(stateToken('unknown'), glyph('unknown', caps), caps)} ${cut(t('dashboard.frame.notRunning', { run: n(v.runId) }), Math.max(0, width - 2), more)}`];
98
+ }
99
+ if (status === 'completed') {
100
+ const sha = v.commit ? v.commit.slice(0, 7) : '';
101
+ return [paint('green', cut(`${glyph('done', caps)} ${sha ? t('dashboard.frame.committed', { sha }) : word}`, width, more), caps)];
102
+ }
103
+ const lines = [cut(t('dashboard.frame.none'), width, more)];
104
+ const ahead = v.steps.find((s) => s.state === 'pending' && s.id in GATE_STEP);
105
+ if (ahead)
106
+ lines.push(paint('muted', cut(t('dashboard.frame.next', { gate: GATE_STEP[ahead.id] }), width, more), caps));
107
+ else if (waiting > 0)
108
+ lines.push(paint('muted', cut(tn('dashboard.frame.waitingCount', waiting), width, more), caps));
109
+ return lines;
110
+ }
111
+ // ---- panel bodies -------------------------------------------------------------------------------------------------
112
+ /** Lines the Pipeline needs for this run (a retry adds a nested line). */
113
+ const pipelineLines = (sel) => (sel ? sel.view.steps.reduce((a, s) => a + 1 + Math.max(0, s.attempts.length - 1), 0) : 1);
114
+ function pipelineBody(sel, width, height, caps, now) {
115
+ if (!sel)
116
+ return [paint('muted', cut(t('dashboard.top.noRun'), width, ellipsis(caps)), caps)];
117
+ const running = sel.view.status === 'running';
118
+ const lines = renderTimeline(sel.view, { ...caps, columns: width }, now, { hints: false, live: !running || sel.liveness === 'live', elapsed: running && sel.liveness === 'live' });
119
+ if (lines.length <= height)
120
+ return lines;
121
+ let active = 0, at = 0;
122
+ const steps = sel.view.steps;
123
+ let found = false;
124
+ for (const s of steps) {
125
+ if (!found && (s.state === 'running' || s.state === 'waiting' || s.state === 'failed')) {
126
+ active = at;
127
+ found = true;
128
+ }
129
+ at += 1 + Math.max(0, s.attempts.length - 1);
130
+ }
131
+ if (!found)
132
+ active = Math.max(0, lines.length - 1);
133
+ return lines.slice(clamp(active - Math.floor(height / 2), 0, lines.length - height)).slice(0, height);
134
+ }
135
+ const markedLabel = (sel) => (sel && sel.marked > 0 ? tn('dashboard.frame.marked', sel.marked) : undefined);
136
+ function agentsBody(m, ui, width, height, caps, now) {
137
+ const rows = renderAgents(agentRows(m.fixed, m.selected), width, caps, now);
138
+ return rows.slice(clamp(ui.pos.agents, 0, Math.max(0, rows.length - height)));
139
+ }
140
+ function eventsBody(m, ui, width, height, caps) {
141
+ const sel = m.selected;
142
+ return renderEvents(sel?.events ?? [], { offset: clamp(ui.pos.events, 0, Math.max(0, (sel?.events.length ?? 0) - 1)), height, width, skipped: sel?.skipped ?? 0, cut: sel?.cut ?? false }, caps);
143
+ }
144
+ function runsBody(m, ui, width, height, caps, now) {
145
+ return renderRuns(m.runs, { cursor: ui.pos.runs, ...(m.selected ? { selected: m.selected.runId } : {}), width, height }, caps, now);
146
+ }
147
+ function body(kind, m, ui, width, height, caps, now) {
148
+ const waiting = m.runs.filter((r) => r.status === 'waiting-approval').length;
149
+ switch (kind) {
150
+ case 'pipeline': return pipelineBody(m.selected, width, height, caps, now);
151
+ case 'approvals': return renderApprovals(m.selected, waiting, width, caps, ui.approveHere === true);
152
+ case 'runs': return runsBody(m, ui, width, height, caps, now);
153
+ case 'agents': return agentsBody(m, ui, width, height, caps, now);
154
+ case 'events': return eventsBody(m, ui, width, height, caps);
155
+ }
156
+ }
157
+ // ---- frame --------------------------------------------------------------------------------------------------------
158
+ function footer(m, ui, caps, keysOnly) {
159
+ const keys = FOOTER_KEYS();
160
+ if (m.readError !== undefined)
161
+ return renderFooter(keys, `${glyph('failed', caps)} ${t('dashboard.frame.readFailed', { time: clock(m.lastChange) })}`, caps, 'red');
162
+ if (ui.notice)
163
+ return renderFooter(keys, n(ui.notice), caps);
164
+ if (keysOnly)
165
+ return renderFooter(keys, '', caps);
166
+ return renderFooter(keys, `${t('dashboard.frame.readOnly')} ${mark('sep', caps)} ${t('dashboard.frame.lastChange', { time: clock(m.lastChange) })}`, caps);
167
+ }
168
+ function topBar(m, caps) {
169
+ const sel = m.selected;
170
+ const ready = m.fixed.squad.filter((s) => s.state !== 'blocked').length;
171
+ return renderTopBar({
172
+ version: m.fixed.version, repo: m.fixed.repo, ...(m.fixed.branch ? { branch: m.fixed.branch } : {}),
173
+ ...(sel ? { run: { short: shortOf(m, sel), status: sel.view.status, liveness: sel.liveness } } : {}),
174
+ ready, total: m.fixed.squad.length, acceptedRisks: m.fixed.acceptedRisks.length,
175
+ }, caps);
176
+ }
177
+ const boxed = (kind, title, right, m, ui, w, h, caps, now, focused) => panel({ title, ...(right ? { right } : {}), body: body(kind, m, ui, w - 4, h - 2, caps, now), width: w, height: h, focused }, caps);
178
+ function approvalsRight(m) {
179
+ const waiting = m.runs.filter((r) => r.status === 'waiting-approval').length;
180
+ return waiting > 0 ? tn('dashboard.frame.waitingCount', waiting) : undefined;
181
+ }
182
+ function wide(m, ui, caps, now) {
183
+ const mid = caps.rows - 3, lw = 50, rw = caps.columns - lw - 1;
184
+ const f = (k) => ui.focus === k;
185
+ const pH = Math.min(pipelineLines(m.selected) + 2, mid - 4 - 5), aH = 4, rH = mid - pH - aH;
186
+ const left = [
187
+ ...boxed('pipeline', TITLE.pipeline(), markedLabel(m.selected), m, ui, lw, pH, caps, now, f('pipeline')),
188
+ ...boxed('approvals', TITLE.approvals(), approvalsRight(m), m, ui, lw, aH, caps, now, f('approvals')),
189
+ ...boxed('runs', TITLE.runs(), undefined, m, ui, lw, rH, caps, now, f('runs')),
190
+ ];
191
+ const gH = Math.min(m.fixed.squad.length + 2, mid - 3), eH = mid - gH;
192
+ const right = [
193
+ ...boxed('agents', TITLE.agents(), undefined, m, ui, rw, gH, caps, now, f('agents')),
194
+ ...boxed('events', TITLE.events(), undefined, m, ui, rw, eH, caps, now, f('events')),
195
+ ];
196
+ return [topBar(m, caps), '', ...left.map((l, i) => `${l} ${right[i] ?? ''}`), footer(m, ui, caps, false)];
197
+ }
198
+ function stacked(m, ui, caps, now) {
199
+ const mid = caps.rows - 2, w = caps.columns;
200
+ const aH = mid >= 13 ? 4 : 3;
201
+ const pH = Math.max(3, Math.min(pipelineLines(m.selected) + 2, mid - aH - 6));
202
+ const tH = mid - aH - pH;
203
+ const tab = ui.tab, labels = ['runs', 'agents', 'events'].map((k) => ({ k, text: `${TITLE[k]()} ${k === 'events' ? 'l' : k[0]}` }));
204
+ let tabPanel = boxed(tab, labels.map((l) => l.text).join(' · '), undefined, m, ui, w, tH, caps, now, ui.focus === tab);
205
+ const shown = labels.find((l) => l.k === tab).text;
206
+ if (tabPanel.length > 0)
207
+ tabPanel = [tabPanel[0].replace(shown, bold(shown, caps)), ...tabPanel.slice(1)];
208
+ return [
209
+ topBar(m, caps),
210
+ ...boxed('pipeline', TITLE.pipeline(), markedLabel(m.selected), m, ui, w, pH, caps, now, ui.focus === 'pipeline'),
211
+ ...boxed('approvals', TITLE.approvals(), approvalsRight(m), m, ui, w, aH, caps, now, ui.focus === 'approvals'),
212
+ ...tabPanel,
213
+ footer(m, ui, caps, false),
214
+ ];
215
+ }
216
+ function narrow(m, ui, caps, now) {
217
+ const w = caps.columns, sel = m.selected;
218
+ const lead = ` ${caps.charset === 'utf8' ? '▙' : '#'} `;
219
+ let top;
220
+ if (!sel)
221
+ top = paint('mint', lead, caps) + paint('muted', cut(t('dashboard.top.noRun'), Math.max(0, w - displayWidth(lead)), ellipsis(caps)), caps);
222
+ else {
223
+ const status = sel.view.status, state = runState(status, sel.liveness);
224
+ const st = `${glyph(state, caps)} ${statusWord(status, sel.liveness)}`;
225
+ const head = cut(shortOf(m, sel), Math.max(0, w - displayWidth(lead) - displayWidth(st) - 1), ellipsis(caps));
226
+ top = paint('mint', lead, caps) + head + ' ' + paint(stateToken(state), st, caps);
227
+ }
228
+ const action = sel ? ' ' + renderApprovals(sel, 0, w - 1, caps, ui.approveHere === true)[0] : '';
229
+ const kind = ui.focus, count = markedLabel(sel);
230
+ const title = count ? `${TITLE[kind]()} ${mark('sep', caps)} ${count}` : TITLE[kind]();
231
+ const h = caps.rows - 3;
232
+ const right = kind === 'approvals' ? approvalsRight(m) : undefined;
233
+ const sec = section({ title, ...(right ? { right } : {}), body: body(kind, m, ui, w, h - 1, caps, now), width: w, height: h }, caps);
234
+ return [top, action, ...sec, footer(m, ui, caps, true)];
235
+ }
236
+ /** The one message below 40 × 12 (or in plain / non-interactive mode): what is needed, what there is, and `taskquoin status`. */
237
+ function tooSmall(caps) {
238
+ const ascii = caps.charset !== 'utf8', x = ascii ? 'x' : '×';
239
+ const need = `40 ${x} 12`, have = `${caps.columns} ${x} ${caps.rows}`, cmd = 'taskquoin status';
240
+ let text = t('dashboard.tooSmall', { need: need.replaceAll(' ', NBSP), have: have.replaceAll(' ', NBSP), cmd: cmd.replaceAll(' ', NBSP) });
241
+ if (ascii)
242
+ text = text.replaceAll('—', '-');
243
+ return wrap(text, caps.columns).map((l) => l.replaceAll(NBSP, ' '));
244
+ }
245
+ function overlay(frame, ui, caps) {
246
+ return boxOver(frame, renderHelp(ui.screen, caps.columns, caps, ui.approveHere === true), caps);
247
+ }
248
+ /** The quit question while `taskquoin approve` still runs: it continues, quitting does not stop it, q quits, Esc stays. */
249
+ function quitBox(q, caps) {
250
+ const fold = (s) => (caps.charset === 'utf8' ? s : s.replaceAll('—', '-').replaceAll('·', '-'));
251
+ const w = Math.max(1, Math.min(caps.columns, 64)), inner = Math.max(1, w - 4);
252
+ const body = [...wrap(fold(t('dashboard.quit.body', { short: n(q.short), pid: q.pid })), inner), '', bold(fold(t('dashboard.quit.keys')), caps)];
253
+ return panel({ title: fold(t('dashboard.quit.title')), body, width: w, height: body.length + 2, focused: true }, caps);
254
+ }
255
+ function boxOver(frame, box, caps) {
256
+ const midH = caps.rows - 2;
257
+ const shown = box.slice(0, midH);
258
+ const top = 1 + Math.floor((midH - shown.length) / 2);
259
+ const indent = ' '.repeat(Math.max(0, Math.floor((caps.columns - displayWidth(shown[0] ?? '')) / 2)));
260
+ const out = frame.slice();
261
+ for (let i = 1; i <= midH; i++)
262
+ out[i] = i >= top && i < top + shown.length ? indent + shown[i - top] : '';
263
+ return out;
264
+ }
265
+ export function renderDashboard(m, ui, caps, now) {
266
+ const mode = layoutMode(caps);
267
+ let lines;
268
+ if (mode === 'too-small')
269
+ lines = tooSmall(caps);
270
+ else {
271
+ lines = mode === 'wide' ? wide(m, ui, caps, now) : mode === 'stacked' ? stacked(m, ui, caps, now) : narrow(m, ui, caps, now);
272
+ if (ui.screen === 'viewer' && ui.viewer)
273
+ lines = renderViewer(ui.viewer, caps, caps.rows);
274
+ else if (ui.screen === 'center' && ui.center) {
275
+ // the run's top bar, then the centre: the keyboard belongs to the form (no help overlay there)
276
+ const top = topBar(m, caps);
277
+ lines = mode === 'narrow' ? [top, ...ui.center.render(caps, caps.rows - 1)] : [top, '', ...ui.center.render(caps, caps.rows - 2)];
278
+ }
279
+ if (ui.help && ui.screen !== 'center')
280
+ lines = overlay(lines, ui, caps);
281
+ if (ui.quit)
282
+ lines = boxOver(lines, quitBox(ui.quit, caps), caps);
283
+ }
284
+ if (mode === 'too-small' && ui.quit) {
285
+ // even below 40 × 12 the question is asked in words: the run goes on, q quits, Esc stays
286
+ const fold = (s) => (caps.charset === 'utf8' ? s : s.replaceAll('—', '-').replaceAll('·', '-'));
287
+ lines = wrap(fold(`${t('dashboard.quit.body', { short: n(ui.quit.short), pid: ui.quit.pid })} ${mark('sep', caps)} ${t('dashboard.quit.keys')}`), caps.columns);
288
+ }
289
+ const out = [];
290
+ for (let i = 0; i < caps.rows; i++)
291
+ out.push(clip(lines[i] ?? '', caps.columns));
292
+ return out;
293
+ }