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,185 @@
1
+ import { glyph, paint, stateToken } from "../tokens.js";
2
+ import { cutNeutral, n } from "../neutral.js";
3
+ import { displayWidth, padEndDisplay } from "../../i18n/width.js";
4
+ import { t, tn } from "../../i18n/index.js";
5
+ import { homeMode, LOGO_ROWS, LOGO_SIDE_COL, renderLogo } from "./logo.js";
6
+ export { homeMode, LOGO_ROWS };
7
+ /** Taskquoin's own sandboxed Verify, the last member of the squad (projectSquad). Not an agent: it is not in the agents count. */
8
+ const TESTER_WHO = 'verify · bubblewrap';
9
+ const isTester = (m) => m.who === TESTER_WHO;
10
+ const INDENT = 2;
11
+ /** Segments painted and clipped to `max` columns: the tail is cut (with an ellipsis), never an escape. */
12
+ function line(segs, max, caps) {
13
+ let left = max, out = '';
14
+ for (const [tok, text] of segs) {
15
+ if (!text)
16
+ continue;
17
+ if (left <= 0)
18
+ break;
19
+ const w = displayWidth(text);
20
+ const shown = w <= left ? text : cutNeutral(text, left, { ascii: caps.charset === 'ascii' });
21
+ left -= displayWidth(shown);
22
+ out += tok ? paint(tok, shown, caps) : shown;
23
+ }
24
+ return out;
25
+ }
26
+ /**
27
+ * A note fitted to `max` columns on a word boundary, with an ellipsis when something is left out. A text already cut
28
+ * mid-word by an earlier stage (it ends with an ellipsis) loses that partial word. A single word longer than the room
29
+ * is cut by characters, the only case a word is split.
30
+ */
31
+ export function wordCut(text, max, ascii = false) {
32
+ const more = ascii ? '...' : '…';
33
+ if (max <= 0)
34
+ return '';
35
+ const cut = text.endsWith('…') || text.endsWith('...');
36
+ if (!cut && displayWidth(text) <= max)
37
+ return text;
38
+ const body = text.replace(/(…|\.\.\.)$/, '');
39
+ const words = body.split(' ').filter(Boolean);
40
+ if (cut)
41
+ words.pop();
42
+ while (words.length && displayWidth(words.join(' ')) + displayWidth(more) > max)
43
+ words.pop();
44
+ if (words.length)
45
+ return words.join(' ') + more;
46
+ return cutNeutral(body, max, { ascii });
47
+ }
48
+ /** Text wrapped on spaces to `width` columns. */
49
+ function wrap(text, width) {
50
+ const lines = [];
51
+ let cur = '';
52
+ for (const w of text.match(/\S+ {0,2}/g) ?? []) {
53
+ if (cur && displayWidth((cur + w).trimEnd()) > width) {
54
+ lines.push(cur.trimEnd());
55
+ cur = w;
56
+ }
57
+ else
58
+ cur += w;
59
+ }
60
+ if (cur)
61
+ lines.push(cur.trimEnd());
62
+ return lines.length ? lines : [''];
63
+ }
64
+ /** What a refusal says, shortened by meaning: a version mismatch is "not measured", never a cut sentence. */
65
+ function blockedNote(raw, compact) {
66
+ const m = /measured for \S+ (\S+?)(?:,|\s|$)/.exec(raw);
67
+ if (m)
68
+ return compact ? t('home.note.notMeasuredShort') : t('home.note.notMeasured', { version: n(m[1]) });
69
+ return raw;
70
+ }
71
+ function noteOf(m, compact) {
72
+ if (m.state === 'ready')
73
+ return '';
74
+ const raw = m.note ? n(m.note) : '';
75
+ if (m.state === 'blocked')
76
+ return blockedNote(raw, compact);
77
+ return compact || !raw ? t('home.note.risk') : t('home.note.riskNote', { note: raw });
78
+ }
79
+ function actionLines(m, caps, width, withBlocked) {
80
+ const out = [];
81
+ const texts = m.notices.map(x => ({ kind: x.kind, text: n(x.text) }));
82
+ const blocked = m.squad.filter(x => x.state === 'blocked').length;
83
+ if (withBlocked && blocked && !texts.some(x => x.kind === 'action')) {
84
+ texts.push({ kind: 'action', text: `${glyph('waiting', caps)} ${t('home.action.label')} ${tn('home.action.blocked', blocked)}` });
85
+ }
86
+ for (const x of texts) {
87
+ const rows = wrap(x.text, width - INDENT - 3);
88
+ rows.forEach((r, i) => {
89
+ const pad = i ? ' '.repeat(INDENT + 3) : ' '.repeat(INDENT);
90
+ if (x.kind === 'action')
91
+ out.push(line([[undefined, pad], ['orange', r]], width, caps));
92
+ else if (!i && r.startsWith('⬆'))
93
+ out.push(line([[undefined, pad], ['cyan', '⬆'], ['muted', r.slice(1)]], width, caps));
94
+ else
95
+ out.push(line([[undefined, pad], ['muted', r]], width, caps));
96
+ });
97
+ }
98
+ return out;
99
+ }
100
+ const repoShort = (repo) => { const p = repo.replace(/\/+$/, '').split('/'); return p[p.length - 1] || repo; };
101
+ function counts(m) {
102
+ const agents = m.squad.filter(x => !isTester(x));
103
+ const tester = m.squad.find(isTester);
104
+ return { agents: agents.length, ready: agents.filter(x => x.state !== 'blocked').length, ...(tester ? { tester: tester.state !== 'blocked' } : {}), risks: m.policy.acceptedRisks.length };
105
+ }
106
+ export function renderHome(m, caps) {
107
+ const mode = homeMode(caps);
108
+ const ascii = caps.charset === 'ascii';
109
+ const width = mode === 'full' ? Math.min(caps.columns, 100) : caps.columns;
110
+ const c = counts(m);
111
+ const squad = m.squad.map(x => ({ ...x, role: n(x.role), who: n(x.who) }));
112
+ const version = n(m.version);
113
+ const repo = n(m.repo), branch = m.branch === undefined ? undefined : n(m.branch);
114
+ const ready = t('console.banner.ready'), notReady = t('console.banner.notReady');
115
+ const stateW = Math.max(displayWidth(ready), displayWidth(notReady));
116
+ const word = (x) => (x.state === 'blocked' ? notReady : ready);
117
+ const treeWord = (short) => (m.clean === undefined ? '' : m.clean ? t(short ? 'home.tree.cleanShort' : 'home.tree.clean') : t(short ? 'home.tree.dirtyShort' : 'home.tree.dirty'));
118
+ const okGlyph = (v) => [v ? 'green' : 'red', glyph(v ? 'done' : 'failed', caps)];
119
+ const out = [];
120
+ if (mode === 'minimal') {
121
+ const roleW = Math.min(Math.max(0, ...squad.map(x => displayWidth(x.role))), 12);
122
+ out.push(line([[undefined, renderLogo(caps, version)[0]], [undefined, ` · ${repoShort(repo)}${branch ? ` (${branch})` : ''}`]], width, caps));
123
+ out.push(line([[undefined, [t('home.min.agents', { ready: c.ready, total: c.agents }), ...(c.tester === undefined ? [] : [t(c.tester ? 'home.min.verifyReady' : 'home.min.verifyNotReady')]),
124
+ ...(c.risks ? [tn('home.min.risk', c.risks)] : [])].join(' · ')]], width, caps));
125
+ for (const x of squad) {
126
+ const role = padEndDisplay(displayWidth(x.role) > roleW ? cutNeutral(x.role, roleW, { ascii }) : x.role, roleW);
127
+ const room = width - displayWidth(glyph(x.state, caps)) - 1 - roleW - 1 - stateW - 1;
128
+ out.push(line([[stateToken(x.state), glyph(x.state, caps)], [undefined, ' ' + role + ' '], [stateToken(x.state), room > 6 && noteOf(x, true) ? padEndDisplay(word(x), stateW) : word(x)],
129
+ [x.state === 'risk' ? 'amber' : 'muted', room > 6 && noteOf(x, true) ? ' ' + wordCut(noteOf(x, true), room, ascii) : '']], width, caps));
130
+ }
131
+ out.push(...actionLines(m, caps, width, false));
132
+ out.push(line([['muted', t('home.min.hint')]], width, caps));
133
+ return out;
134
+ }
135
+ // Full and Compact: the logo (rows 3-4 carry the tagline in Full, the context in Compact), then the squad.
136
+ const labelW = mode === 'full' ? Math.max(...['home.label.repository', 'home.label.sandbox', 'home.label.policy'].map(k => displayWidth(t(k)))) + 2 : 0;
137
+ const side = (s) => line(s, width - LOGO_SIDE_COL, caps);
138
+ const bwOk = m.sandbox.bubblewrap && m.sandbox.socat;
139
+ const risksText = c.risks ? tn('home.compact.risk', c.risks) : '';
140
+ const logo = mode === 'full'
141
+ ? renderLogo(caps, version)
142
+ : renderLogo(caps, version, [
143
+ side([[undefined, repo], ['muted', branch ? ` ${branch}${treeWord(true) ? ' · ' + treeWord(true) : ''}` : treeWord(true) ? ' ' + treeWord(true) : '']]),
144
+ side([[undefined, 'sandbox '], okGlyph(bwOk && m.sandbox.verify), ...(risksText ? [['muted', ' · ' + risksText]] : [])])
145
+ ]);
146
+ out.push(...logo);
147
+ out.push('');
148
+ const tester = squad.find(isTester);
149
+ const summary = tn('home.squad.summary', c.agents, { ready: c.ready });
150
+ if (mode === 'full') {
151
+ const lab = (k) => padEndDisplay(t(k), labelW);
152
+ const tree = [branch, treeWord(false)].filter(Boolean).join(' · ');
153
+ out.push(line([[undefined, ' '.repeat(INDENT)], ['muted', lab('home.label.repository')], [undefined, repo + (tree ? ' ' + tree : '')]], width, caps));
154
+ out.push(line([[undefined, ' '.repeat(INDENT)], ['muted', lab('home.label.sandbox')], okGlyph(m.sandbox.bubblewrap), [undefined, ' bubblewrap '], okGlyph(m.sandbox.socat), [undefined, ' socat · '],
155
+ [m.sandbox.verify ? undefined : 'red', t(m.sandbox.verify ? 'home.sandbox.verify' : 'home.sandbox.noVerify')]], width, caps));
156
+ const until = [...m.policy.acceptedRisks].map(r => n(r.expires)).sort()[0];
157
+ out.push(line([[undefined, ' '.repeat(INDENT)], ['muted', lab('home.label.policy')], [undefined, `taskquoin.yaml ${n(m.policy.digest).slice(0, 12)} · `],
158
+ [c.risks ? 'amber' : undefined, c.risks ? tn('home.policy.risk', c.risks, { date: until }) : t('home.policy.noRisk')]], width, caps));
159
+ out.push('');
160
+ const right = [summary, ...(tester ? [t(tester.state === 'blocked' ? 'home.verify.notReady' : 'home.verify.ready')] : [])].join(' · ');
161
+ const title = t('home.squad.title');
162
+ const fill = Math.max(2, width - INDENT - 3 - displayWidth(title) - 1 - 1 - displayWidth(right) - 1 - 2);
163
+ out.push(line([[undefined, ' '.repeat(INDENT)], ['line', '── '], [undefined, title + ' '], ['line', '─'.repeat(fill) + ' '], ['muted', right + ' '], ['line', '──']], width, caps));
164
+ }
165
+ const rows = squad;
166
+ const roleW = Math.min(Math.max(...rows.map(x => displayWidth(x.role))), Math.max(8, Math.floor(width / 4)));
167
+ const whoOf = (x) => (mode === 'full' ? x.who : (x.who.includes(' · ') ? x.who.slice(x.who.indexOf(' · ') + 3) : x.who));
168
+ const fixed = INDENT + 2 + roleW + 2 + 2 + stateW + 2;
169
+ const whoW = Math.min(Math.max(...rows.map(x => displayWidth(whoOf(x)))), Math.max(6, width - fixed - 4));
170
+ for (const x of rows) {
171
+ const role = displayWidth(x.role) > roleW ? cutNeutral(x.role, roleW, { ascii }) : x.role;
172
+ const who = displayWidth(whoOf(x)) > whoW ? cutNeutral(whoOf(x), whoW, { ascii }) : whoOf(x);
173
+ const note = noteOf(x, mode === 'compact');
174
+ const room = width - fixed - whoW;
175
+ out.push(line([[undefined, ' '.repeat(INDENT)], [stateToken(x.state), glyph(x.state, caps)], [undefined, ' ' + padEndDisplay(role, roleW) + ' '], ['muted', padEndDisplay(who, whoW) + ' '],
176
+ [stateToken(x.state), room >= 6 && note ? padEndDisplay(word(x), stateW) : word(x)], [x.state === 'risk' ? 'amber' : 'muted', room >= 6 && note ? ' ' + wordCut(note, room, ascii) : '']], width, caps));
177
+ }
178
+ if (mode === 'compact')
179
+ out.push(line([[undefined, ' '.repeat(INDENT)], [undefined, t('home.compact.summary', { summary })]], width, caps));
180
+ const actions = actionLines(m, caps, width, mode === 'full');
181
+ if (actions.length)
182
+ out.push('', ...actions);
183
+ out.push('');
184
+ return out;
185
+ }
@@ -0,0 +1,67 @@
1
+ import { paint } from "../tokens.js";
2
+ import { displayWidth } from "../../i18n/width.js";
3
+ import { t } from "../../i18n/index.js";
4
+ /** Full: 100+ columns, 24+ rows; Compact: 70-99 columns or 16-23 rows; Minimal: under 70 columns, under 16 rows, no colour, plain, ASCII. */
5
+ export function homeMode(caps) {
6
+ if (caps.colorDepth === 0 || caps.charset === 'ascii' || caps.plain || caps.columns < 70 || caps.rows < 16)
7
+ return 'minimal';
8
+ return caps.columns < 100 || caps.rows < 24 ? 'compact' : 'full';
9
+ }
10
+ /** Rows the quoin logo takes in Full and Compact. */
11
+ export const LOGO_ROWS = 4;
12
+ /** The mark is 6 cells wide, then 2 of gap; the side text of rows 3 and 4 starts here (after the 2-cell indent). */
13
+ export const LOGO_SIDE_COL = 2 + 6 + 2;
14
+ const STONES = [
15
+ { cells: '██████', token: 'mint' }, { cells: '███', token: 'cyan' }, { cells: '██████', token: 'violet' }, { cells: '███', token: 'orange' },
16
+ ];
17
+ /** T A S K Q U O I N, two rows each; I is one cell wide, N four. */
18
+ const LETTERS = [
19
+ ['▀█▀', ' █ '], ['▄▀▄', '█▀█'], ['█▀▀', '▄▄█'], ['█▄▀', '█ █'], ['▄▀▄', '▀▄█'], ['█ █', '▀▄▀'], ['▄▀▄', '▀▄▀'], ['█', '█'], ['█▄ █', '█ ▀█'],
20
+ ];
21
+ const GRADIENT = ['mint', 'mint', 'mint', 'cyan', 'cyan', 'cyan', 'violet', 'violet', 'violet'];
22
+ const Q = 4;
23
+ const paintSegs = (segs, caps) => segs.map(([tok, s]) => (tok && s ? paint(tok, s, caps) : s)).join('');
24
+ function wordmarkRow(r) {
25
+ const segs = [];
26
+ LETTERS.forEach((l, i) => {
27
+ if (i)
28
+ segs.push([undefined, ' ']);
29
+ const text = l[r];
30
+ if (r === 1 && i === Q)
31
+ segs.push([GRADIENT[i], text.slice(0, -1)], ['orange', text.slice(-1)]);
32
+ else
33
+ segs.push([GRADIENT[i], text]);
34
+ });
35
+ return segs;
36
+ }
37
+ /** The brand on one line: Minimal mode, no colour, plain mode. `▙` in mint when there is colour (`#` without UTF-8). */
38
+ export function brandLine(caps, version) {
39
+ return `${paint('mint', caps.charset === 'utf8' ? '▙' : '#', caps)} taskquoin ${version}`;
40
+ }
41
+ /**
42
+ * The logo as lines. Full and Compact (with colour, UTF-8, 70+ columns): the 4-row mark, the 2-row wordmark, the
43
+ * version right-aligned on row 1; rows 3 and 4 carry `side` (already painted and cut to fit by the caller), by default
44
+ * the tagline and the promise. Otherwise one line: `▙ taskquoin <version>`.
45
+ */
46
+ export function renderLogo(caps, version, side) {
47
+ if (homeMode(caps) === 'minimal')
48
+ return [brandLine(caps, version)];
49
+ const width = Math.min(caps.columns, 100);
50
+ const ver = `v${version}`;
51
+ const rows = [];
52
+ for (let i = 0; i < LOGO_ROWS; i++) {
53
+ const stone = STONES[i];
54
+ const mark = paint(stone.token, stone.cells, caps) + ' '.repeat(6 - stone.cells.length);
55
+ if (i < 2) {
56
+ const word = wordmarkRow(i);
57
+ const used = 2 + 6 + 2 + word.reduce((w, [, s]) => w + displayWidth(s), 0);
58
+ const gap = i === 0 ? Math.max(1, width - used - displayWidth(ver)) : 0;
59
+ rows.push(' ' + mark + ' ' + paintSegs(word, caps) + (i === 0 ? ' '.repeat(gap) + paint('muted', ver, caps) : ''));
60
+ }
61
+ else {
62
+ const text = side?.[i - 2] ?? (i === 2 ? paint('orange', t('console.banner.tagline'), caps) : paint('muted', t('console.banner.promise'), caps));
63
+ rows.push(' ' + mark + ' ' + text);
64
+ }
65
+ }
66
+ return rows;
67
+ }
@@ -0,0 +1,70 @@
1
+ import { bold, ellipsis, paint } from "../tokens.js";
2
+ import { clip, cut, pad } from "../text.js";
3
+ import { displayWidth } from "../../i18n/width.js";
4
+ const rule = (caps) => caps.charset === 'utf8' ? { h: '─', left: '╭', right: '╮', v: '│' } : { h: '-', left: '+', right: '+', v: '|' };
5
+ /** `─ Title ──── right ─` of `inner` columns: title cut first, right label kept while it fits. */
6
+ function head(title, right, inner, caps, token, titleStyle) {
7
+ const h = rule(caps).h;
8
+ const dash = (n) => paint(token, h.repeat(Math.max(0, n)), caps);
9
+ let r = right !== undefined && right !== '' ? right : undefined;
10
+ let budget = () => inner - 2 - 2 - (r === undefined ? 0 : displayWidth(r) + 2 + 1);
11
+ if (r !== undefined && budget() < 1) {
12
+ r = cut(r, Math.max(0, inner - 2 - 2 - 1 - 1 - 2), ellipsis(caps));
13
+ if (r === '' || budget() < 1)
14
+ r = undefined;
15
+ }
16
+ budget = () => inner - 2 - 2 - (r === undefined ? 0 : displayWidth(r) + 2 + 1);
17
+ if (budget() < 1)
18
+ return dash(inner);
19
+ const t = cut(title, budget(), ellipsis(caps));
20
+ const tw = displayWidth(t);
21
+ const rw = r === undefined ? 0 : displayWidth(r) + 2;
22
+ const fill = inner - 1 - (tw + 2) - rw - 1;
23
+ const muted = (s) => paint('muted', s, caps);
24
+ return dash(1) + paint(token, ' ', caps) + titleStyle(t) + paint(token, ' ', caps) + dash(fill)
25
+ + (r === undefined ? '' : paint(token, ' ', caps) + muted(r) + paint(token, ' ', caps)) + dash(1);
26
+ }
27
+ export function panel(o, caps) {
28
+ const { width, height } = o;
29
+ if (height <= 0)
30
+ return [];
31
+ if (width < 4)
32
+ return Array.from({ length: height }, () => ' '.repeat(Math.max(0, width)));
33
+ const token = o.focused ? 'mint' : 'line';
34
+ const r = rule(caps);
35
+ const edge = (s) => paint(token, s, caps);
36
+ const titleStyle = (s) => (o.focused ? bold(paint('mint', s, caps), caps) : paint('muted', s, caps));
37
+ const out = [edge(r.left) + head(o.title, o.right, width - 2, caps, token, titleStyle) + edge(r.right)];
38
+ if (height === 1)
39
+ return out;
40
+ const inner = width - 4;
41
+ for (let i = 0; i < height - 2; i++) {
42
+ const text = clip(o.body[i] ?? '', inner);
43
+ out.push(edge(r.v) + ' ' + pad(text, inner) + ' ' + edge(r.v));
44
+ }
45
+ out.push(edge(r.left === '╭' ? '╰' : '+') + paint(token, r.h.repeat(width - 2), caps) + edge(r.left === '╭' ? '╯' : '+'));
46
+ return out;
47
+ }
48
+ /** Borderless: a `── Title ── right ──` rule, then the body; for 40–79 columns. */
49
+ export function section(o, caps) {
50
+ const { width, height } = o;
51
+ if (height <= 0)
52
+ return [];
53
+ const h = rule(caps).h;
54
+ const fill = (n) => paint('line', h.repeat(Math.max(0, n)), caps);
55
+ let line;
56
+ if (width < 8)
57
+ line = fill(width);
58
+ else {
59
+ const rt = o.right !== undefined && o.right !== '' ? cut(o.right, Math.max(1, Math.floor(width / 3)), ellipsis(caps)) : undefined;
60
+ const rw = rt === undefined ? 0 : displayWidth(rt) + 2 + 2;
61
+ const t = cut(o.title, Math.max(1, width - 2 - 2 - 1 - rw), ellipsis(caps));
62
+ const used = 2 + 1 + displayWidth(t) + 1 + (rt === undefined ? 0 : 1 + displayWidth(rt) + 1 + 2);
63
+ line = fill(2) + paint('line', ' ', caps) + bold(t, caps) + paint('line', ' ', caps)
64
+ + (rt === undefined ? fill(width - used) : fill(width - used) + paint('line', ' ', caps) + paint('muted', rt, caps) + paint('line', ' ', caps) + fill(2));
65
+ }
66
+ const out = [line];
67
+ for (let i = 0; i < height - 1; i++)
68
+ out.push(pad(clip(o.body[i] ?? '', width), width));
69
+ return out;
70
+ }
@@ -0,0 +1,96 @@
1
+ import { t, tn } from "../../i18n/index.js";
2
+ import { displayWidth } from "../../i18n/width.js";
3
+ import { n } from "../neutral.js";
4
+ import { cut } from "../text.js";
5
+ import { bold, ellipsis, glyph, paint, stateToken } from "../tokens.js";
6
+ /** `running` is shown running only when the process is known alive; otherwise it is unknown (`not running?`). */
7
+ export function runState(status, liveness) {
8
+ switch (status) {
9
+ case 'running': return liveness === 'live' ? 'running' : 'unknown';
10
+ case 'waiting-approval':
11
+ case 'needs-human': return 'waiting';
12
+ case 'completed': return 'done';
13
+ case 'failed': return 'failed';
14
+ case 'interrupted': return 'interrupted';
15
+ default: return 'unknown';
16
+ }
17
+ }
18
+ export function statusWord(status, liveness) {
19
+ switch (status) {
20
+ case 'running': return liveness === 'live' ? t('dashboard.status.running') : t('dashboard.status.notRunning');
21
+ case 'waiting-approval': return t('dashboard.status.waiting');
22
+ case 'needs-human': return t('dashboard.status.needsHuman');
23
+ case 'completed': return t('dashboard.status.done');
24
+ case 'failed': return t('dashboard.status.failed');
25
+ case 'interrupted': return t('dashboard.status.interrupted');
26
+ default: return t('dashboard.status.unreadable');
27
+ }
28
+ }
29
+ const widthOf = (segs) => segs.reduce((a, [s]) => a + displayWidth(s), 0);
30
+ const paintSegs = (segs, caps) => segs.map(([s, tok]) => (tok ? paint(tok, s, caps) : s)).join('');
31
+ export function renderTopBar(m, caps) {
32
+ const ascii = caps.charset !== 'utf8';
33
+ const logo = ascii ? '#' : '▙', bar = ascii ? '|' : '│', dot = ascii ? '-' : '·';
34
+ const state = m.run ? runState(m.run.status, m.run.liveness) : undefined;
35
+ const stateSeg = () => [`${glyph(state, caps)} ${statusWord(m.run.status, m.run.liveness)}`, stateToken(state)];
36
+ const runSegs = () => (m.run ? [[t('dashboard.top.run', { short: n(m.run.short) }) + ' '], stateSeg()] : [[t('dashboard.top.noRun'), 'muted']]);
37
+ const flags = { version: true, branch: true, risks: true, ready: true, repo: true, name: true };
38
+ const build = (k) => {
39
+ const parts = [];
40
+ parts.push([[logo, 'mint'], ...(k.name ? [[` taskquoin${k.version && m.version ? ' ' + n(m.version) : ''}`, 'muted']] : [])]);
41
+ if (k.repo)
42
+ parts.push([[n(m.repo)], ...(k.branch && m.branch ? [[' ' + n(m.branch), 'muted']] : [])]);
43
+ parts.push(runSegs());
44
+ if (k.ready) {
45
+ const agents = [[t('dashboard.top.agents', { ready: m.ready, total: m.total })]];
46
+ if (k.risks && m.acceptedRisks > 0)
47
+ agents.push([` ${dot} ${tn('dashboard.top.risks', m.acceptedRisks)}`, 'muted']);
48
+ parts.push(agents);
49
+ }
50
+ return parts.flatMap((p, i) => (i === 0 ? p : [[` ${bar} `, 'line'], ...p]));
51
+ };
52
+ const order = ['version', 'branch', 'risks', 'ready', 'repo', 'name'];
53
+ const k = { ...flags };
54
+ for (let i = 0;; i++) {
55
+ const segs = [[' '], ...build(k)];
56
+ if (widthOf(segs) <= caps.columns)
57
+ return paintSegs(segs, caps);
58
+ if (i === order.length)
59
+ break;
60
+ k[order[i]] = false;
61
+ }
62
+ // Only the logo and the run remain. If that is still too wide, the run id is cut first; the glyph and word stay.
63
+ const lead = [[' '], [logo, 'mint'], [' ']];
64
+ const room = caps.columns - widthOf(lead);
65
+ if (!m.run)
66
+ return paintSegs([...lead, [cut(t('dashboard.top.noRun'), Math.max(0, room), ellipsis(caps)), 'muted']], caps);
67
+ const st = stateSeg();
68
+ const head = cut(t('dashboard.top.run', { short: n(m.run.short) }), Math.max(0, room - displayWidth(st[0]) - 1), ellipsis(caps));
69
+ return paintSegs([...lead, ...(head ? [[head + ' ']] : []), st], caps);
70
+ }
71
+ /**
72
+ * `key label` pairs on the left, `right` at the right edge, `caps.columns` columns when there is a right text. Labels go
73
+ * before keys; the right text is cut before any key is lost.
74
+ */
75
+ export function renderFooter(keys, right, caps, rightToken = 'muted') {
76
+ const cols = caps.columns, more = ellipsis(caps);
77
+ const plain = (labels) => keys.map(([k, l]) => (labels && l ? `${k} ${l}` : k)).join(labels ? ' ' : ' ');
78
+ const styled = (labels) => keys.map(([k, l]) => (labels && l ? `${bold(k, caps)} ${paint('muted', l, caps)}` : bold(k, caps))).join(labels ? ' ' : ' ');
79
+ const line = (labels, r) => {
80
+ const gap = Math.max(1, cols - 1 - displayWidth(plain(labels)) - displayWidth(r));
81
+ return ` ${styled(labels)}${r ? ' '.repeat(gap) + paint(rightToken, r, caps) : ''}`;
82
+ };
83
+ const fits = (labels, r) => 1 + displayWidth(plain(labels)) + (r ? 2 + displayWidth(r) : 0) <= cols;
84
+ const rest = (labels) => cols - 1 - displayWidth(plain(labels)) - 2;
85
+ if (fits(true, right))
86
+ return line(true, right);
87
+ if (right && rest(true) >= 12)
88
+ return line(true, cut(right, rest(true), more));
89
+ if (fits(false, right))
90
+ return line(false, right);
91
+ if (right && rest(false) >= 4)
92
+ return line(false, cut(right, rest(false), more));
93
+ if (fits(false, ''))
94
+ return line(false, '');
95
+ return ' ' + cut(plain(false), Math.max(0, cols - 1), more);
96
+ }
@@ -0,0 +1,120 @@
1
+ import { t } from "../../i18n/index.js";
2
+ import { displayWidth, padEndDisplay } from "../../i18n/width.js";
3
+ import { clock, cut as textCut, duration } from "../text.js";
4
+ import { n } from "../neutral.js";
5
+ import { glyph, paint, stateToken } from "../tokens.js";
6
+ const LABEL = {
7
+ planning: () => t('timeline.step.planning'), critique: () => t('timeline.step.critique'), 'plan-approval': () => t('timeline.step.planApproval'),
8
+ implementation: () => t('timeline.step.implementation'), verify: () => t('timeline.step.verify'), 'red-proof': () => t('timeline.step.redProof'),
9
+ review: () => t('timeline.step.review'), 'commit-approval': () => t('timeline.step.commitApproval'), commit: () => t('timeline.step.commit'),
10
+ };
11
+ const valid = (iso) => { const ms = iso ? Date.parse(iso) : NaN; return Number.isFinite(ms) ? ms : undefined; };
12
+ /** An already neutral string cut to `max` columns, no ellipsis (the callers have already made room for what follows). */
13
+ const cut = (s, max) => textCut(s, max, '');
14
+ const arrow = (caps) => (caps.charset === 'utf8' ? '→' : '->');
15
+ const bar = (caps) => (caps.charset === 'utf8' ? '│' : '|');
16
+ /** Glyph state and the word that always travels with it (AC-3: state = glyph + word, never dropped). */
17
+ function stateOf(view, s, live) {
18
+ switch (s.state) {
19
+ case 'pending': return { name: 'pending', word: t('timeline.state.pending') };
20
+ case 'done': return { name: 'done', word: t('timeline.state.done') };
21
+ case 'running': return live ? { name: 'running', word: t('timeline.state.running') } : { name: 'unknown', word: t('dashboard.status.notRunning') };
22
+ case 'waiting': return { name: 'waiting', word: t('timeline.state.waiting') };
23
+ case 'unknown': return { name: 'unknown', word: t('timeline.state.unknown') }; // a status this projection does not know: never a failure
24
+ default:
25
+ return view.status === 'interrupted' ? { name: 'interrupted', word: t('timeline.state.interrupted') }
26
+ : view.status === 'needs-human' ? { name: 'failed', word: t('timeline.state.needsHuman') } : { name: 'failed', word: t('timeline.state.failed') };
27
+ }
28
+ }
29
+ const attemptState = (outcome) => outcome === 'running' ? 'running' : /rework|^(failed|needs-human|interrupted)$/.test(outcome) ? 'failed' : 'done';
30
+ const WORD = { running: () => t('timeline.state.running'), failed: () => t('timeline.state.failed'), done: () => t('timeline.state.done') };
31
+ /**
32
+ * The state word (`must`) is never dropped. Optional columns go from the right until the line fits (hint, then
33
+ * duration, end time, agent · runtime); the label is cut last, to what the glyph and the word leave.
34
+ */
35
+ function fit(lead, label, must, cols, max) {
36
+ let keep = cols.filter(c => c !== '');
37
+ const width = (l, cs) => displayWidth(lead) + displayWidth(l) + 2 + displayWidth(must) + cs.reduce((a, c) => a + 2 + displayWidth(c), 0);
38
+ while (keep.length && width(label, keep) > max)
39
+ keep = keep.slice(0, -1);
40
+ return { label: width(label, keep) > max ? cut(label, Math.max(0, max - displayWidth(lead) - 2 - displayWidth(must))) : label, cols: keep };
41
+ }
42
+ export function renderTimeline(view, caps, now, o = {}) {
43
+ const show = o.slash === false ? 'show' : '/show';
44
+ const hints = o.hints !== false, live = o.live !== false, elapsed = o.elapsed !== false;
45
+ const labels = view.steps.map(s => LABEL[s.id]());
46
+ const lw = Math.min(Math.max(...labels.map(displayWidth)), Math.max(8, Math.floor(caps.columns / 3)));
47
+ const lines = [];
48
+ view.steps.forEach((s, i) => {
49
+ const st = stateOf(view, s, live);
50
+ const lead = ` ${glyph(st.name, caps)} `;
51
+ const who = s.agent ? `${n(s.agent)}${s.runtime ? ` · ${n(s.runtime)}` : ''}` : '';
52
+ const main = s.artifacts.find(a => a === 'plan' || a === 'challenge'); // `memory`, `challenge-<judge>` are for /show to list
53
+ const att = s.attempts.length > 1 ? t('timeline.attempt', { n: s.attempts.length }) : '';
54
+ const hint = s.attempts.length ? (hints && s.attempts.at(-1).artifact ? `${show} ${n(s.attempts.at(-1).artifact)}` : '')
55
+ : s.state === 'waiting' && view.pending ? view.pending.binding.slice(0, 12)
56
+ : s.state === 'done' && main && hints ? `${show} ${main}` : '';
57
+ let at = '', took = '';
58
+ if (s.state === 'done' || (s.state === 'failed' && s.endedAt)) {
59
+ at = clock(s.endedAt);
60
+ took = duration(s.durationMs);
61
+ }
62
+ else if (s.state === 'running' && !live) { /* a dead process: no start-to-now figure that keeps growing */ }
63
+ else if (s.state === 'running' || s.state === 'waiting' || s.state === 'failed') {
64
+ const from = valid(s.startedAt);
65
+ if (elapsed)
66
+ took = from === undefined ? '?' : duration(now - from);
67
+ else
68
+ at = clock(s.startedAt);
69
+ }
70
+ const label = padEndDisplay(labels[i], lw);
71
+ // A pending step has no agent, time or hint yet: glyph, name and word.
72
+ const f = fit(lead, label, st.word, [who, at, took, att, hint], caps.columns);
73
+ lines.push(` ${paint(stateToken(st.name), glyph(st.name, caps), caps)} ${f.label} ${paint(stateToken(st.name), st.word, caps)}${f.cols.map(c => ' ' + c).join('')}`);
74
+ // A retry is nested under the step it repeats; the last attempt is the step's own line.
75
+ for (const a of s.attempts.slice(0, -1)) {
76
+ const as = attemptState(a.outcome);
77
+ const word = WORD[as]();
78
+ const l = ` ${bar(caps)} ${glyph(as, caps)} `;
79
+ const text = fit(l, t('timeline.attempt', { n: a.n }), word, [n(a.outcome), hints && a.artifact ? `${show} ${n(a.artifact)}` : ''], caps.columns);
80
+ lines.push(` ${bar(caps)} ${paint(stateToken(as), glyph(as, caps), caps)} ${text.label} ${paint(stateToken(as), word, caps)}${text.cols.map(c => ' ' + c).join('')}`);
81
+ }
82
+ });
83
+ return lines;
84
+ }
85
+ /** One append-only line for an event of the run; undefined for the events that are not progress. */
86
+ export function timelineLine(event, caps) {
87
+ const s = (k) => (typeof event[k] === 'string' && event[k] !== '' ? n(event[k]) : '?');
88
+ const num = (k) => (typeof event[k] === 'number' ? String(event[k]) : '?');
89
+ let state, text;
90
+ switch (event.type) {
91
+ case 'node.transition':
92
+ state = 'done';
93
+ text = `${s('node')} ${s('outcome')} ${arrow(caps)} ${s('next')}`;
94
+ break;
95
+ case 'agent.started':
96
+ state = 'running';
97
+ text = t('timeline.p.started', { agent: s('agent'), runtime: s('runtime') });
98
+ break;
99
+ case 'agent.finished': {
100
+ const ok = event.status === 'completed';
101
+ state = ok ? 'done' : 'failed';
102
+ const ms = typeof event.durationMs === 'number' ? duration(event.durationMs) : '?';
103
+ const model = typeof event.model === 'string' && event.model !== '' ? ` · ${n(event.model)}` : '';
104
+ text = t(ok ? 'timeline.p.finished' : 'timeline.p.finishedFailed', { agent: s('agent'), runtime: s('runtime'), duration: ms, status: s('status') }) + model;
105
+ break;
106
+ }
107
+ case 'verify.result':
108
+ state = event.passed === true ? 'done' : 'failed';
109
+ text = t(event.passed === true ? 'timeline.p.verifyPassed' : 'timeline.p.verifyFailed', { n: num('attempt'), code: num('exitCode') });
110
+ break;
111
+ case 'red.result':
112
+ state = event.redFailed === true ? 'done' : event.redFailed === false ? 'failed' : 'unknown';
113
+ text = t(event.redFailed === true ? 'timeline.p.redProven' : event.redFailed === false ? 'timeline.p.redNotProven' : 'timeline.p.redInconclusive', { n: num('attempt') });
114
+ break;
115
+ default: return undefined;
116
+ }
117
+ const at = typeof event.ts === 'string' && valid(event.ts) !== undefined ? `${clock(event.ts)} ` : '';
118
+ const lead = ` ${glyph(state, caps)} `;
119
+ return ` ${paint(stateToken(state), glyph(state, caps), caps)} ${cut(at + text, Math.max(1, caps.columns - displayWidth(lead)))}`;
120
+ }