@2cmddev/2cmd 0.0.0-stage → 0.1.5

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 (93) hide show
  1. package/.opencode/command/2cmd-audit.md +5 -0
  2. package/.opencode/command/2cmd-debt.md +5 -0
  3. package/.opencode/command/2cmd-gain.md +5 -0
  4. package/.opencode/command/2cmd-help.md +5 -0
  5. package/.opencode/command/2cmd-review.md +5 -0
  6. package/.opencode/command/2cmd.md +5 -0
  7. package/.opencode/plugins/2cmd-frontmatter.cjs +63 -0
  8. package/.opencode/plugins/2cmd.mjs +206 -0
  9. package/.opencode/plugins/index.js +4 -0
  10. package/.qoder/rules/2cmd.md +31 -0
  11. package/.qoder-plugin/plugin.json +16 -0
  12. package/.zcode-plugin/plugin.json +13 -0
  13. package/AGENTS.md +33 -0
  14. package/LICENSE +22 -0
  15. package/README.md +133 -2
  16. package/codex/answer.mjs +164 -0
  17. package/codex/data.mjs +31 -0
  18. package/codex/pty.py +80 -0
  19. package/codex/stats.mjs +105 -0
  20. package/codex/terminal.mjs +388 -0
  21. package/dsh/LICENSE +22 -0
  22. package/dsh/board.js +782 -0
  23. package/dsh/build.mjs +47 -0
  24. package/dsh/bundle.json +2104 -0
  25. package/dsh/client.js +877 -0
  26. package/dsh/cordis.patch.yml +3 -0
  27. package/dsh/index.js +185 -0
  28. package/dsh/ledger.js +50 -0
  29. package/dsh/market.js +152 -0
  30. package/dsh/package.json +24 -0
  31. package/dsh/prices.json +1812 -0
  32. package/dsh/settings-text.mjs +520 -0
  33. package/dsh/settings.js +42 -0
  34. package/dsh/stats.js +106 -0
  35. package/dsh/store.js +32 -0
  36. package/dsh/update-prices.mjs +9 -0
  37. package/dsh/update.js +27 -0
  38. package/dsh/voice-helper/Info.plist +13 -0
  39. package/dsh/voice-helper/Transcript.swift +21 -0
  40. package/dsh/voice-helper/build.sh +10 -0
  41. package/dsh/voice-helper/main.swift +70 -0
  42. package/dsh/voice-helper/test.swift +17 -0
  43. package/dsh/voice.js +63 -0
  44. package/hooks/2cmd-activate.js +219 -0
  45. package/hooks/2cmd-antigravity.js +64 -0
  46. package/hooks/2cmd-band-import.js +305 -0
  47. package/hooks/2cmd-config.js +186 -0
  48. package/hooks/2cmd-instructions.js +104 -0
  49. package/hooks/2cmd-map.js +200 -0
  50. package/hooks/2cmd-mode-tracker.js +248 -0
  51. package/hooks/2cmd-runtime.js +245 -0
  52. package/hooks/2cmd-statusline.ps1 +24 -0
  53. package/hooks/2cmd-statusline.sh +18 -0
  54. package/hooks/2cmd-subagent.js +100 -0
  55. package/hooks/band/board.ts +720 -0
  56. package/hooks/band/buttons.ts +60 -0
  57. package/hooks/band/i18n/de.ts +149 -0
  58. package/hooks/band/i18n/en.ts +150 -0
  59. package/hooks/band/i18n/es.ts +149 -0
  60. package/hooks/band/i18n/fr.ts +149 -0
  61. package/hooks/band/i18n/index.ts +42 -0
  62. package/hooks/band/i18n/ja.ts +149 -0
  63. package/hooks/band/i18n/ko.ts +149 -0
  64. package/hooks/band/i18n/pt.ts +149 -0
  65. package/hooks/band/i18n/ru.ts +149 -0
  66. package/hooks/band/i18n/vi.ts +149 -0
  67. package/hooks/band/i18n/zh-Hans.ts +149 -0
  68. package/hooks/band/i18n/zh-Hant.ts +149 -0
  69. package/hooks/band/logo.ts +3 -0
  70. package/hooks/band/metrics.ts +373 -0
  71. package/hooks/band/register.tsx +681 -0
  72. package/hooks/band/types.d.ts +45 -0
  73. package/hooks/band/windows-board.mjs +20 -0
  74. package/hooks/claude-band.json +6 -0
  75. package/hooks/claude-codex-hooks.json +41 -0
  76. package/hooks/codebuddy-hooks.json +20 -0
  77. package/hooks/copilot-hooks.json +21 -0
  78. package/hooks/cursor-hooks.json +17 -0
  79. package/hooks/qoder-hooks.json +26 -0
  80. package/hooks/zcode-hooks.json +26 -0
  81. package/package.json +56 -4
  82. package/pi-extension/index.js +258 -0
  83. package/pi-extension/names.js +19 -0
  84. package/pi-extension/package.json +8 -0
  85. package/scripts/cursor-hooks.js +145 -0
  86. package/scripts/uninstall.js +92 -0
  87. package/skills/2cmd/SKILL.md +55 -0
  88. package/skills/2cmd-audit/SKILL.md +105 -0
  89. package/skills/2cmd-debt/SKILL.md +46 -0
  90. package/skills/2cmd-gain/SKILL.md +53 -0
  91. package/skills/2cmd-help/SKILL.md +87 -0
  92. package/skills/2cmd-review/SKILL.md +143 -0
  93. package/skills/plugin.json +5 -0
@@ -0,0 +1,720 @@
1
+ // The task board: one self-contained HTML page built from the band's CSV ledgers.
2
+ // No server and no network: inline CSS, inline SVG and a few lines of script.
3
+
4
+ import { fill } from './i18n'
5
+ import type { Locale, Strings } from './i18n'
6
+ import { LOGO_PATHS, LOGO_VIEWBOX } from './logo'
7
+ import { COMMANDS, DEFAULT_BUTTONS, MAX_LABEL, buttonKinds } from './buttons'
8
+ import type { Host, PanelButton } from './buttons'
9
+
10
+ export const duration = (minutes: number) =>
11
+ minutes < 60 ? `${minutes}m` : `${Math.floor(minutes / 60)}h ${minutes % 60}m`
12
+
13
+ // Agent time reads better with seconds while it is short.
14
+ export const elapsed = (ms: number) => {
15
+ const s = Math.round(ms / 1000)
16
+ if (s < 60) return `${s}s`
17
+ if (s < 3600) return `${Math.floor(s / 60)}m ${s % 60}s`
18
+ return duration(Math.round(s / 60))
19
+ }
20
+
21
+ export const fmtTokens = (n: number) =>
22
+ n < 1000 ? `${n}` : n < 1e6 ? `${+(n / 1e3).toFixed(1)}k` : `${+(n / 1e6).toFixed(1)}M`
23
+
24
+ // 只翻译显示文字:CSV 里仍存英文,旧记录和看板分类都依赖它。
25
+ export const testsText = (s: string, t: Strings) =>
26
+ s.replace('passed', t.passed).replace('failed', t.failed).replace('stale', t.stale).replace('not run', t.notRun)
27
+
28
+ export type Task = {
29
+ started: string
30
+ project: string
31
+ name: string
32
+ cost: number | null // null: a model without a price (DSH only)
33
+ turns: number
34
+ agentMinutes: number
35
+ tokens: number
36
+ output?: number // output tokens; not every host logs them
37
+ reuse: number | null
38
+ tests: string
39
+ level: string
40
+ mode?: string // hosts whose rows say "import" keep the 2Cmd mode here (DSH, Codex, ZCode)
41
+ model: string
42
+ }
43
+
44
+ // With and without 2Cmd, from the person's own tasks. Tasks are paired by project and model, each pair
45
+ // gives the ratio of its medians, and the pairs are averaged weighted by their smaller side. With fewer than
46
+ // COMPARE_MIN tasks on either side the board says so instead of a number.
47
+ // shortcut: a pairing, not a controlled test: the two sides still did different work. benchmarks/ is the controlled one.
48
+ export const COMPARE_MIN = 10
49
+ export type Comparison = { on: number; off: number; change?: { cost: number | null; output: number | null; turns: number | null } }
50
+
51
+ const median = (xs: number[]) => {
52
+ const v = [...xs].sort((a, b) => a - b)
53
+ return v.length % 2 ? v[(v.length - 1) / 2] : (v[v.length / 2 - 1] + v[v.length / 2]) / 2
54
+ }
55
+
56
+ export function compareModes(tasks: Task[]): Comparison {
57
+ const pairs = new Map<string, { on: Task[]; off: Task[] }>()
58
+ for (const t of tasks) {
59
+ const mode = t.mode ?? t.level
60
+ if (!mode || mode === 'import') continue // nobody knows whether 2Cmd was on
61
+ const key = `${t.project}\n${t.model}`
62
+ if (!pairs.has(key)) pairs.set(key, { on: [], off: [] })
63
+ pairs.get(key)![mode === 'off' ? 'off' : 'on'].push(t)
64
+ }
65
+ const both = [...pairs.values()].filter(p => p.on.length > 0 && p.off.length > 0)
66
+ const on = both.reduce((n, p) => n + p.on.length, 0)
67
+ const off = both.reduce((n, p) => n + p.off.length, 0)
68
+ if (on < COMPARE_MIN || off < COMPARE_MIN) return { on, off }
69
+ // Lower is better for all three; a task without the value (no price, no output count) stays out.
70
+ const change = (pick: (t: Task) => number | null) => {
71
+ let weight = 0
72
+ let sum = 0
73
+ for (const p of both) {
74
+ const a = p.on.map(pick).filter((v): v is number => v !== null && v > 0)
75
+ const b = p.off.map(pick).filter((v): v is number => v !== null && v > 0)
76
+ if (!a.length || !b.length) continue
77
+ const w = Math.min(a.length, b.length)
78
+ sum += w * Math.log(median(a) / median(b))
79
+ weight += w
80
+ }
81
+ return weight ? Math.exp(sum / weight) - 1 : null
82
+ }
83
+ return {
84
+ on,
85
+ off,
86
+ change: {
87
+ cost: change(t => t.cost),
88
+ output: change(t => (t.output && t.turns ? t.output / t.turns : null)),
89
+ turns: change(t => t.turns),
90
+ },
91
+ }
92
+ }
93
+
94
+ // RFC 4180 rows: quoted fields may hold commas, doubled quotes and line breaks.
95
+ export function parseCsv(text: string): string[][] {
96
+ const rows: string[][] = []
97
+ let row: string[] = []
98
+ let field = ''
99
+ let quoted = false
100
+ for (let i = 0; i < text.length; i++) {
101
+ const c = text[i]
102
+ if (quoted) {
103
+ if (c === '"' && text[i + 1] === '"') {
104
+ field += '"'
105
+ i++
106
+ } else if (c === '"') quoted = false
107
+ else field += c
108
+ } else if (c === '"') quoted = true
109
+ else if (c === ',') {
110
+ row.push(field)
111
+ field = ''
112
+ } else if (c === '\n' || c === '\r') {
113
+ if (c === '\r' && text[i + 1] === '\n') i++
114
+ row.push(field)
115
+ if (row.some(f => f !== '')) rows.push(row)
116
+ row = []
117
+ field = ''
118
+ } else field += c
119
+ }
120
+ row.push(field)
121
+ if (row.some(f => f !== '')) rows.push(row)
122
+ return rows
123
+ }
124
+
125
+ export function tasksFrom(text: string): Task[] {
126
+ const [head, ...rows] = parseCsv(text)
127
+ if (!head?.includes('key')) return []
128
+ const at = (row: string[], col: string) => row[head.indexOf(col)] ?? ''
129
+ const num = (row: string[], col: string) => Number(at(row, col)) || 0
130
+ return rows.map(row => ({
131
+ started: at(row, 'started'),
132
+ project: at(row, 'project'),
133
+ name: at(row, 'name'),
134
+ cost: num(row, 'cost_usd'),
135
+ turns: num(row, 'turns'),
136
+ agentMinutes: num(row, 'agent_minutes'),
137
+ tokens: num(row, 'tokens_total'),
138
+ output: num(row, 'tokens_output'),
139
+ reuse: at(row, 'reuse_pct') === '' ? null : num(row, 'reuse_pct'),
140
+ tests: at(row, 'tests'),
141
+ level: at(row, 'level'),
142
+ model: at(row, 'model'),
143
+ }))
144
+ }
145
+
146
+ const esc = (s: string) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
147
+
148
+ // Project colours, in sidebar order; the share card carries a gradient for each.
149
+ const PALETTE = ['#5fe08a', '#7c8cff', '#2fd4c0', '#ff8a3d', '#ff6fb5', '#ffd166', '#4cc3ff', '#b26bff']
150
+
151
+ const LIGHT = 'color-scheme:light;--bg:#f5f5f3;--panel:#fff;--card:#fff;--line:#ebeae6;--line2:#dedcd6;--text:#1d1c1a;--muted:#77756f;--faint:#a9a7a0;--track:#f2f1ed;--segOn:#fff;--tip:#1d1c1a;--tipText:#fff;--ok:#2f7d3b;--okbg:#e8f5e9;--bad:#b4401b;--badbg:#fcebe4;--warn:#946200;--warnbg:#fbf2d7;--nonebg:#f2f1ed;--empty:#eeede9;--tint:.12;--glow:.45;--shadow:0 1px 2px rgba(25,25,15,.05)'
152
+ // Windows has none of the Mac fonts: without its own names it falls back to a serif monospace and SimSun.
153
+ const MONO_CSS = '"JetBrains Mono",ui-monospace,"SF Mono",SFMono-Regular,Menlo,"Cascadia Mono","Cascadia Code",Consolas,"Microsoft YaHei UI",monospace'
154
+ const SANS_CSS = 'Inter,-apple-system,BlinkMacSystemFont,"Segoe UI Variable Text","Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei UI","Microsoft YaHei",Roboto,"Noto Sans CJK SC",sans-serif'
155
+
156
+ // Dark is the default; light (chosen, or the system's when "system" is chosen) keeps the same layout.
157
+ const CSS = `:root{color-scheme:dark;--bg:#060606;--panel:#0c0c0c;--card:linear-gradient(180deg,#0f0f0f,#090909);--line:#1c1c1b;--line2:#262624;--text:#f3f2ee;--muted:#8d8b84;--faint:#5e5c55;--track:#141413;--segOn:#1f1f1d;--tip:#050505;--tipText:#f3f2ee;--ok:#5fe08a;--okbg:#122016;--bad:#ff6b5b;--badbg:#2a1210;--warn:#f1c96b;--warnbg:#2a2412;--nonebg:#161615;--empty:#151514;--tint:.2;--glow:1;--shadow:inset 0 1px 0 rgba(255,255,255,.035),0 20px 50px rgba(0,0,0,.35)}
158
+ :root[data-theme=light]{${LIGHT}}
159
+ @media (prefers-color-scheme:light){:root[data-theme=system]{${LIGHT}}}
160
+ *{box-sizing:border-box}html,body{margin:0}body{background:var(--bg);color:var(--text);font:14px/1.5 ${SANS_CSS};-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility}
161
+ html{scrollbar-color:var(--line2) transparent;scrollbar-width:thin}::-webkit-scrollbar{width:10px;height:10px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:var(--line2);border-radius:10px;border:3px solid var(--bg)}
162
+ .num{font-family:${MONO_CSS};font-variant-numeric:tabular-nums;letter-spacing:-.03em}
163
+ .sprite{position:absolute;width:0;height:0;overflow:hidden}
164
+ .app{display:grid;grid-template-columns:264px minmax(0,1fr);min-height:100vh}
165
+ .side{border-right:1px solid var(--line);padding:24px 16px 14px;display:flex;flex-direction:column;gap:2px;position:sticky;top:0;height:100vh;overflow:hidden}
166
+ #projects{flex:1 1 auto;min-height:0;overflow-y:auto;margin:0 -6px;padding:0 6px}
167
+ .brand{display:flex;align-items:center;gap:10px;font:600 15px/1 ${MONO_CSS};padding:0 10px 24px}
168
+ .logo{width:28px;height:28px;flex:none}.logo svg{width:100%;height:100%;display:block}
169
+ .side-label{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--faint);padding:6px 10px}
170
+ .nav-item{display:flex;align-items:center;gap:10px;width:100%;border:0;background:transparent;color:var(--muted);font:inherit;padding:8px 10px;border-radius:10px;cursor:pointer;text-align:left}
171
+ .nav-item .name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
172
+ .nav-item:hover,.nav-item.on{background:var(--track);color:var(--text)}
173
+ .nav-item .n{font:12px ${MONO_CSS};color:var(--faint)}
174
+ .dot{width:8px;height:8px;border-radius:50%;flex:none;background:var(--c);box-shadow:0 0 10px var(--c)}
175
+ .side-foot{flex:none;margin-top:8px;display:flex;align-items:center;gap:8px;padding:10px 0 0;border-top:1px solid var(--line)}.side-foot .nav-item{flex:1;min-width:0}.side-foot .theme{margin-left:auto}
176
+ .theme{display:grid;place-items:center;width:34px;height:34px;flex:none;border:0;border-radius:9px;background:transparent;color:var(--muted);cursor:pointer}.theme:hover{background:var(--track);color:var(--text)}.theme svg{display:none}.theme[data-choice=system] .i-system,.theme[data-choice=light] .i-light,.theme[data-choice=dark] .i-dark{display:block}
177
+ main{padding:26px 32px 56px;min-width:0;max-width:1400px;width:100%;margin:0 auto}
178
+ .top{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;margin-bottom:22px;flex-wrap:wrap}
179
+ .crumb{color:var(--faint);font-size:13px}.crumb b{color:var(--muted);font-weight:500}
180
+ h1{margin:2px 0 0;font-size:26px;font-weight:650;letter-spacing:-.02em}.top p{margin:2px 0 0;color:var(--muted)}
181
+ .actions{display:flex;gap:10px;align-items:center}
182
+ .seg{display:inline-flex;background:var(--track);border:1px solid var(--line);border-radius:12px;padding:3px;flex:none}
183
+ .seg button{border:0;background:transparent;color:var(--muted);font:inherit;font-size:13px;padding:6px 12px;border-radius:9px;cursor:pointer}
184
+ .seg button.on{background:var(--segOn);color:var(--text);box-shadow:inset 0 1px 0 rgba(255,255,255,.06),0 0 0 1px var(--line2)}
185
+ .btn{border:1px solid var(--line2);background:var(--track);color:var(--text);font:inherit;font-size:13px;padding:8px 14px;border-radius:11px;cursor:pointer}.btn:hover{border-color:var(--faint)}
186
+ .card{background:var(--card);border:1px solid var(--line);border-radius:22px;box-shadow:var(--shadow)}
187
+ .kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:14px}
188
+ .kpi{padding:18px 20px 0;position:relative;overflow:hidden}
189
+ .kpi::after{content:"";position:absolute;left:0;right:0;bottom:0;height:75%;background:radial-gradient(120% 100% at 50% 135%,var(--k),transparent 70%);opacity:var(--tint);pointer-events:none}
190
+ .kpi-label{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px}
191
+ .kpi-label::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--k);box-shadow:0 0 10px var(--k)}
192
+ .kpi-value{font-size:30px;margin-top:4px;white-space:nowrap}
193
+ .delta{font:12px ${MONO_CSS};margin-left:8px;vertical-align:6px}.up{color:var(--ok)}.down{color:var(--bad)}
194
+ .kpi-note{color:var(--faint);font-size:12px}
195
+ .spark{display:block;width:calc(100% + 40px);height:58px;margin:10px -20px 0;position:relative;z-index:1}
196
+ .glow-line{opacity:calc(var(--glow) * .8)}
197
+ .chart-card{padding:22px 24px 18px;margin-bottom:14px}
198
+ .chart-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;flex-wrap:wrap}
199
+ .label{color:var(--muted);font-size:13px}.big{font-size:40px;line-height:1.15;margin-top:2px}
200
+ .chart-wrap{position:relative;margin-top:6px}
201
+ #stream{display:block;width:100%;height:340px;overflow:visible}
202
+ .axis{fill:var(--faint);font:11px ${MONO_CSS}}.base{stroke:var(--line2)}.empty-chart{fill:var(--faint);font-size:13px}
203
+ .glow{opacity:calc(var(--glow) * .14)}.top-line{stroke:var(--text);stroke-opacity:.35;fill:none}
204
+ .hover-line{stroke:var(--text);stroke-opacity:.5}
205
+ .tip{position:absolute;pointer-events:none;background:var(--tip);color:var(--tipText);border:1px solid var(--line2);border-radius:12px;padding:7px 11px;font-size:12px;transform:translate(-50%,calc(-100% - 12px));white-space:nowrap;box-shadow:0 10px 30px rgba(0,0,0,.35)}
206
+ .tip-date{opacity:.65}.tip-value{font:600 13px ${MONO_CSS}}
207
+ .legend{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
208
+ .chip{display:inline-flex;align-items:center;gap:8px;padding:6px 10px;border-radius:10px;background:var(--track);border:1px solid var(--line);color:var(--text);font:inherit;font-size:13px;cursor:pointer}
209
+ .chip .x{color:var(--faint)}.chip[aria-pressed=false]{opacity:.45}
210
+ .grid2{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr);gap:14px;align-items:start}
211
+ .list{padding:20px 0 6px}
212
+ .list-head{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:0 22px 14px}
213
+ h3{margin:0;font-size:15px;font-weight:600}h3 .n{color:var(--faint);font-weight:400;margin-left:4px}
214
+ .search{display:flex;align-items:center;gap:8px;background:var(--track);border:1px solid var(--line);border-radius:10px;padding:6px 10px;width:220px;color:var(--faint)}
215
+ .search input{border:0;outline:0;background:transparent;color:var(--text);font:inherit;font-size:13px;width:100%}
216
+ .table-wrap{overflow-x:auto}
217
+ table{width:100%;border-collapse:collapse;font-size:13px}
218
+ th{text-align:left;font-weight:400;color:var(--faint);font-size:12px;padding:0 10px 10px;white-space:nowrap}
219
+ th:first-child,td:first-child{padding-left:22px}th:last-child,td:last-child{padding-right:22px}
220
+ td{padding:11px 10px;border-top:1px solid var(--line);white-space:nowrap;vertical-align:middle}
221
+ th.r,td.r{text-align:right}
222
+ td.name{white-space:normal;min-width:140px;width:100%;max-width:0}.task{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sub{font-size:12px;color:var(--faint)}
223
+ .bar{height:3px;border-radius:2px;margin-top:6px;background:linear-gradient(90deg,var(--c),transparent)}
224
+ .pill{display:inline-flex;align-items:center;gap:6px;font-size:12px;padding:3px 9px;border-radius:999px;background:var(--nonebg);color:var(--muted)}
225
+ .pill i{width:6px;height:6px;border-radius:50%;background:currentColor}
226
+ .pill.ok{background:var(--okbg);color:var(--ok)}.pill.bad{background:var(--badbg);color:var(--bad)}.pill.warn{background:var(--warnbg);color:var(--warn)}
227
+ td.empty{text-align:center;color:var(--faint);padding:32px}
228
+ .cmp-card{padding:20px 22px;margin-bottom:14px}.cmp-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin:12px 0 8px}.cmp-label{color:var(--muted);font-size:13px}.cmp-value{font-size:28px}
229
+ .heat{padding:20px 22px}.heat .sub{margin:2px 0 14px}
230
+ #heat{display:block;width:100%;height:auto}.cell-empty{fill:var(--empty)}.glow-cell{opacity:calc(var(--glow) * .45)}.day{fill:var(--faint);font:12px ${MONO_CSS}}
231
+ .heroes{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-top:20px}.hero-label{display:flex;align-items:center;gap:7px;color:var(--muted);font-size:12px}.hero-label i{font-style:normal;font-size:11px}.hero-value{font-size:30px;margin-top:4px;white-space:nowrap}.hero-sub{font-size:12px;color:var(--faint);margin-top:2px}.hero-sub b{color:var(--ok);font-weight:500;margin-right:6px}
232
+ #facts{margin-top:16px}.fact{display:flex;justify-content:space-between;gap:12px;padding:11px 0;border-top:1px solid var(--line);color:var(--muted)}.fact .num{color:var(--text)}
233
+ footer{color:var(--faint);font-size:12px;margin-top:22px}
234
+ dialog{border:1px solid var(--line);border-radius:18px;padding:0;background:var(--panel);color:var(--text);box-shadow:0 24px 70px rgba(0,0,0,.4);width:min(840px,92vw)}
235
+ dialog::backdrop{background:rgba(0,0,0,.55)}
236
+ .dlg-head{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:14px 18px;border-bottom:1px solid var(--line)}
237
+ .dlg-actions{display:flex;gap:8px}.btn-help{margin:0 0 14px;color:var(--muted);font-size:13px}
238
+ .btn-head,.btn-row{display:grid;grid-template-columns:64px minmax(140px,200px) minmax(90px,130px) minmax(0,1fr);gap:8px;align-items:center}.btn-head{color:var(--faint);font-size:12px;margin-bottom:6px}.btn-row{margin-bottom:10px}.btn-row b{font-size:13px;font-weight:600}
239
+ #btn-dialog select,#btn-dialog input,#btn-dialog textarea{box-sizing:border-box;width:100%;min-width:0;border:1px solid var(--line2);background-color:var(--track);color:var(--text);font:inherit;font-size:13px;padding:8px 10px;border-radius:10px;outline:0}
240
+ #btn-dialog input:focus,#btn-dialog select:focus,#btn-dialog textarea:focus{border-color:var(--faint)}#btn-dialog input:disabled{opacity:.45}
241
+ #btn-dialog select{appearance:none;-webkit-appearance:none;cursor:pointer;padding-right:34px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d8b84' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center}
242
+ #btn-dialog option{background:var(--panel);color:var(--text)}
243
+ .btn:focus:not(:focus-visible){outline:none}.btn.primary{background:var(--text);color:var(--bg);border-color:var(--text);font-weight:600}.btn.primary:hover{opacity:.9}
244
+ .toast{position:fixed;left:50%;bottom:28px;transform:translateX(-50%);background:var(--tip);color:var(--tipText);border:1px solid var(--line2);border-radius:12px;padding:10px 16px;font-size:13px;box-shadow:0 10px 30px rgba(0,0,0,.35);z-index:10}
245
+ @media (max-width:640px){.btn-head{display:none}.btn-row{grid-template-columns:1fr 1fr}.btn-row b{grid-column:1/-1}}#btn-command{margin-top:6px;font-family:monospace;resize:vertical}.btn-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:10px;font-size:12px;color:var(--muted)}.btn-foot .btn:disabled{opacity:.5;cursor:default}.dlg-body{padding:18px}.dlg-body svg{width:100%;height:auto;display:block;border-radius:12px}
246
+ @media (max-width:1360px){.kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
247
+ @media (max-width:1100px){.grid2{grid-template-columns:minmax(0,1fr)}}
248
+ @media (max-width:860px){.app{grid-template-columns:minmax(0,1fr)}.side{position:static;height:auto;overflow:visible;flex-direction:row;flex-wrap:wrap;align-items:center;border-right:0;border-bottom:1px solid var(--line)}
249
+ .side-label{display:none}.side-foot{margin:0 0 0 auto;padding:0;border:0}.side-foot .nav-item{flex:none}#projects{overflow:visible;margin:0;padding:0}.brand{padding:2px 10px}#projects{display:flex;gap:4px;flex-wrap:wrap}.nav-item{width:auto}
250
+ main{padding:16px}.search{width:160px}.big{font-size:32px}}
251
+ @media (max-width:520px){.kpis,.cmp-row{grid-template-columns:minmax(0,1fr)}.top .actions{width:100%;justify-content:space-between}.list-head{flex-wrap:wrap}.search{width:100%}}`
252
+
253
+ // The page draws itself from the JSON block: project picker, period, charts and table need no reload.
254
+ // Names only ever reach the page as text (textContent), never as HTML.
255
+ const APP = `(function () {
256
+ var D = JSON.parse(document.getElementById('board-data').textContent)
257
+ var tasks = D.tasks, now = D.now, DAY = 86400000, NS = 'http://www.w3.org/2000/svg'
258
+ var state = { project: '', metric: 'time', q: '', period: 30, hidden: {} }
259
+ var T = D.t
260
+ function F(text, values) { return text.replace(/\\{(\\w+)\\}/g, function (whole, key) { return key in values ? values[key] : whole }) }
261
+ function testsText(s) { return s.replace('passed', T.passed).replace('failed', T.failed).replace('stale', T.stale).replace('not run', T.notRun) }
262
+ function dateText(key, options) { return new Date(+key.slice(0, 4), key.slice(5, 7) - 1, +key.slice(8, 10)).toLocaleDateString(D.lang, options) }
263
+ var PALETTE = ${JSON.stringify(PALETTE)}
264
+ // Each KPI its own colour pair, apart from the project colours: the line runs from one to the other.
265
+ var KPI = [['sessions', '#4cc3ff', '#7c8cff'], ['time', '#2fd4c0', '#5fe08a'], ['cost', '#ffd166', '#ff8a3d'], ['tokens', '#ff6fb5', '#b26bff']]
266
+ function byId(id) { return document.getElementById(id) }
267
+ function h(tag, cls, text) { var e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e }
268
+ function svg(tag, attrs, parent) { var e = document.createElementNS(NS, tag); for (var k in attrs) e.setAttribute(k, attrs[k]); if (parent) parent.append(e); return e }
269
+ function two(n) { return (n < 10 ? '0' : '') + n }
270
+ function dayKey(ms) { var d = new Date(ms); return d.getFullYear() + '-' + two(d.getMonth() + 1) + '-' + two(d.getDate()) }
271
+ // claude-opus-5-5 reads as Opus 5.5; a trailing date in the id is dropped.
272
+ function modelName(m) { var p = m.replace(/^claude-/, '').split('-'); return p[0] ? p[0][0].toUpperCase() + p[0].slice(1) + (p.length > 1 ? '\\u00a0' + p.slice(1).filter(function (x) { return x.length < 3 }).join('.') : '') : '' }
273
+ function shortDate(key) { return dateText(key, { month: 'short', day: 'numeric' }) }
274
+ function dur(min) { return min < 60 ? min + 'm' : Math.floor(min / 60) + 'h ' + (min % 60) + 'm' }
275
+ function time(ms) { var s = Math.round(ms / 1000); return s < 60 ? s + 's' : s < 3600 ? Math.floor(s / 60) + 'm ' + (s % 60) + 's' : dur(Math.round(s / 60)) }
276
+ function tok(n) { return n < 1000 ? String(Math.round(n)) : n < 1e6 ? +(n / 1e3).toFixed(1) + 'k' : +(n / 1e6).toFixed(1) + 'M' }
277
+ // Only DSH passes a currency, and only when it is not USD. It has already converted the costs.
278
+ function money(n) { return D.currency ? n.toLocaleString(D.lang, { style: 'currency', currency: D.currency }) : '$' + n.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }
279
+ function add(a, b) { return a + b }
280
+ var METRICS = {
281
+ sessions: { label: T.sessions, pick: function () { return 1 }, fmt: String },
282
+ time: { label: T.time, pick: function (t) { return t.agentMinutes * 60000 }, fmt: time },
283
+ cost: { label: T.cost, pick: function (t) { return t.cost }, fmt: money },
284
+ tokens: { label: T.tokens, pick: function (t) { return t.tokens }, fmt: tok }
285
+ }
286
+ // Sessions without a price stay out of the total and the average, and are never shown as $0.
287
+ function priced(list) { return list.filter(function (t) { return t.cost !== null }) }
288
+ function show(M, list) { return M === METRICS.cost && list.length && !priced(list).length ? '–' : M.fmt(total(list, M.pick)) }
289
+ function total(list, pick) { return list.map(pick).reduce(add, 0) }
290
+ function latest(name) { return tasks.filter(function (t) { return t.project === name }).reduce(function (m, t) { return t.started > m ? t.started : m }, '') }
291
+ var names = Array.from(new Set(tasks.map(function (t) { return t.project }))).sort(function (a, b) { return latest(b).localeCompare(latest(a)) })
292
+ function colorOf(name) { return PALETTE[names.indexOf(name) % PALETTE.length] }
293
+ function scope() { return state.project ? tasks.filter(function (t) { return t.project === state.project }) : tasks }
294
+ function first(list) { return list.reduce(function (m, t) { return !m || t.started < m ? t.started : m }, '') }
295
+ // Days the chosen period covers; "All" reaches back to the first session on screen.
296
+ function span() {
297
+ if (state.period) return state.period
298
+ var f = first(scope())
299
+ return f ? Math.max(7, Math.round((now - new Date(f.slice(0, 10) + 'T00:00').getTime()) / DAY) + 1) : 30
300
+ }
301
+ function days(n) { var out = []; for (var i = n - 1; i >= 0; i--) out.push(dayKey(now - i * DAY)); return out }
302
+ function inDays(list, keys) { return list.filter(function (t) { return keys.indexOf(t.started.slice(0, 10)) >= 0 }) }
303
+ function perDay(list, keys, pick) { return keys.map(function (k) { return total(list.filter(function (t) { return t.started.slice(0, 10) === k }), pick) }) }
304
+ function avg(values, r) { return values.map(function (_, i) { var a = values.slice(Math.max(0, i - r), i + r + 1); return a.reduce(add, 0) / a.length }) }
305
+ // Monotone cubic through the points (as d3's curveMonotoneX): flat at peaks and valleys, never past a point.
306
+ function smooth(p) {
307
+ var n = p.length, m = [], d = 'M' + p[0][0].toFixed(1) + ',' + p[0][1].toFixed(1)
308
+ function slope(i) { return (p[i + 1][1] - p[i][1]) / (p[i + 1][0] - p[i][0]) }
309
+ if (n < 3) return n < 2 ? d : d + 'L' + p[1][0].toFixed(1) + ',' + p[1][1].toFixed(1)
310
+ for (var i = 1; i < n - 1; i++) {
311
+ var s0 = slope(i - 1), s1 = slope(i)
312
+ m[i] = (Math.sign(s0) + Math.sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), Math.abs(s0 + s1) / 4) || 0
313
+ }
314
+ m[0] = (3 * slope(0) - m[1]) / 2; m[n - 1] = (3 * slope(n - 2) - m[n - 2]) / 2
315
+ for (i = 0; i < n - 1; i++) {
316
+ var dx = (p[i + 1][0] - p[i][0]) / 3
317
+ d += 'C' + (p[i][0] + dx).toFixed(1) + ',' + (p[i][1] + m[i] * dx).toFixed(1) + ' ' + (p[i + 1][0] - dx).toFixed(1) + ',' + (p[i + 1][1] - m[i + 1] * dx).toFixed(1) + ' ' + p[i + 1][0].toFixed(1) + ',' + p[i + 1][1].toFixed(1)
318
+ }
319
+ return d
320
+ }
321
+ function gradient(parent, id, x2, y2, stops) {
322
+ var g = svg('linearGradient', { id: id, gradientUnits: 'userSpaceOnUse', x1: 0, y1: 0, x2: x2, y2: y2 }, parent)
323
+ stops.forEach(function (s) { svg('stop', { offset: s[0], 'stop-color': s[1], 'stop-opacity': s[2] }, g) })
324
+ }
325
+ function blur(parent, id, sd) { svg('feGaussianBlur', { stdDeviation: sd }, svg('filter', { id: id, x: '-20%', y: '-50%', width: '140%', height: '200%' }, parent)) }
326
+
327
+ function sidebar() {
328
+ var nav = byId('projects'); nav.textContent = ''
329
+ ;[['', T.allProjects, tasks.length]].concat(names.map(function (n) { return [n, n, tasks.filter(function (t) { return t.project === n }).length] })).forEach(function (p) {
330
+ var b = h('button', 'nav-item' + (state.project === p[0] ? ' on' : '')); b.type = 'button'; b.title = p[1]
331
+ if (p[0]) { var d = h('span', 'dot'); d.style.setProperty('--c', colorOf(p[0])); b.append(d) }
332
+ b.append(h('span', 'name', p[1]), h('span', 'n', String(p[2])))
333
+ b.addEventListener('click', function () { state.project = p[0]; state.hidden = {}; render() })
334
+ nav.append(b)
335
+ })
336
+ }
337
+
338
+ function header() {
339
+ var list = scope(), name = state.project || T.allProjects, f = first(list)
340
+ byId('crumb').textContent = name
341
+ byId('title').textContent = name
342
+ byId('subtitle').textContent = f ? F(T.sinceN, { n: list.length, d: dateText(f, { year: 'numeric', month: 'short', day: 'numeric' }) }) : F(T.sessionsN, { n: list.length })
343
+ }
344
+
345
+ function sparkline(values, i, k) {
346
+ var W = 300, H = 58, s = svg('svg', { viewBox: '0 0 300 58', preserveAspectRatio: 'none', 'class': 'spark', 'aria-hidden': 'true' })
347
+ var vals = values.length > 14 ? avg(values, 2) : values, max = Math.max.apply(null, vals.concat([0]))
348
+ if (max <= 0) return s
349
+ var defs = svg('defs', {}, s)
350
+ gradient(defs, 'kl' + i, W, 0, [[0, k[1], 1], [1, k[2], 1]])
351
+ gradient(defs, 'kf' + i, 0, H, [[0, k[2], .38], [1, k[1], 0]])
352
+ blur(defs, 'kg' + i, 5)
353
+ var line = smooth(vals.map(function (v, j) { return [j * W / Math.max(1, vals.length - 1), H - 6 - v / max * (H - 16)] }))
354
+ svg('path', { d: line + 'L' + W + ',' + H + 'L0,' + H + 'Z', fill: 'url(#kf' + i + ')' }, s)
355
+ svg('path', { d: line, fill: 'none', stroke: 'url(#kl' + i + ')', 'stroke-width': 2, filter: 'url(#kg' + i + ')', 'class': 'glow-line', 'vector-effect': 'non-scaling-stroke' }, s)
356
+ svg('path', { d: line, fill: 'none', stroke: 'url(#kl' + i + ')', 'stroke-width': 1.8, 'vector-effect': 'non-scaling-stroke' }, s)
357
+ return s
358
+ }
359
+
360
+ function kpis() {
361
+ var list = scope(), n = span(), keys = days(n), wrap = byId('kpis'); wrap.textContent = ''
362
+ var cur = inDays(list, keys), prev = state.period ? inDays(list, days(2 * n).slice(0, n)) : []
363
+ KPI.forEach(function (k, i) {
364
+ var M = METRICS[k[0]], v = total(cur, M.pick), p = total(prev, M.pick)
365
+ var card = h('div', 'card kpi'), value = h('div', 'kpi-value num', show(M, cur)); card.style.setProperty('--k', k[2])
366
+ if (p > 0) { var pct = Math.round((v - p) / p * 100); value.append(h('span', 'delta ' + (pct >= 0 ? 'up' : 'down'), (pct >= 0 ? '↑' : '↓') + Math.abs(pct) + '%')) }
367
+ var note = !state.period ? T.allTime : p > 0 ? F(T.vsPrev, { n: n }) : F(T.lastDays, { n: n })
368
+ card.append(h('div', 'kpi-label', M.label), value, h('div', 'kpi-note', note), sparkline(perDay(list, keys, M.pick), i, k))
369
+ wrap.append(card)
370
+ })
371
+ }
372
+
373
+ // Lower is better for all three, so a fall is drawn in the "up" (good) colour.
374
+ function compare() {
375
+ var c = D.compare[state.project] || { on: 0, off: 0 }, box = byId('compare'); box.textContent = ''
376
+ // Always all time, whatever the period buttons say: a period rarely holds enough tasks for both sides.
377
+ box.append(h('h3', '', T.cmpTitle + ' · ' + T.allTime))
378
+ if (!c.change) { box.append(h('div', 'sub', F(T.cmpShort, { on: c.on, off: c.off, n: D.compareMin }))); return }
379
+ var row = h('div', 'cmp-row')
380
+ ;[['cost', T.cmpCost], ['output', T.cmpOutput], ['turns', T.cmpTurns]].forEach(function (m) {
381
+ var v = c.change[m[0]], cell = h('div', 'cmp')
382
+ cell.append(h('div', 'cmp-label', m[1]), h('div', 'cmp-value num ' + (v === null ? '' : v <= 0 ? 'up' : 'down'), v === null ? '–' : (v <= 0 ? '↓' : '↑') + Math.abs(Math.round(v * 100)) + '%'))
383
+ row.append(cell)
384
+ })
385
+ box.append(row, h('div', 'sub', F(T.cmpNote, { on: c.on, off: c.off })))
386
+ }
387
+
388
+ function chart() {
389
+ var list = scope(), n = span(), keys = days(n), M = METRICS[state.metric], box = byId('stream'), tip = byId('tip'); tip.hidden = true
390
+ var W = Math.max(320, Math.round(box.getBoundingClientRect().width) || 900), H = 340, top = 66, base = 282
391
+ box.setAttribute('viewBox', '0 0 ' + W + ' ' + H); box.textContent = ''
392
+ var defs = svg('defs', {}, box); blur(defs, 'sglow', 10)
393
+ var shown = names.filter(function (p) { return (!state.project || p === state.project) && list.some(function (t) { return t.project === p }) })
394
+ var projects = shown.filter(function (p) { return !state.hidden[p] })
395
+ var cur = inDays(list, keys).filter(function (t) { return !state.hidden[t.project] })
396
+ byId('chart-sub').textContent = M.label + ' · ' + (state.period ? F(T.lastDays, { n: n }) : T.allTime)
397
+ byId('chart-total').textContent = show(M, cur)
398
+ legend(shown)
399
+ var x = function (i) { return n > 1 ? i * W / (n - 1) : W / 2 }
400
+ svg('line', { x1: 0, x2: W, y1: base + 22, y2: base + 22, 'class': 'base' }, box)
401
+ for (var w = 0, step = Math.max(1, Math.ceil(n / 6)); w < n; w += step) svg('text', { x: x(w), y: H - 6, 'class': 'axis', 'text-anchor': w ? 'middle' : 'start' }, box).textContent = shortDate(keys[w])
402
+ var raw = projects.map(function (p) { return perDay(cur.filter(function (t) { return t.project === p }), keys, M.pick) })
403
+ // Real day values: the curve passes through them, nothing is spread to neighbouring days.
404
+ var layers = raw
405
+ var totals = keys.map(function (_, i) { return layers.reduce(function (a, r) { return a + r[i] }, 0) })
406
+ var max = Math.max.apply(null, totals.concat([0]))
407
+ if (max <= 0) { svg('text', { x: W / 2, y: (top + base) / 2, 'text-anchor': 'middle', 'class': 'empty-chart' }, box).textContent = T.noPeriod; return }
408
+ var y = function (v) { return base - v / max * (base - top) }, acc = keys.map(function () { return 0 }), shapes = []
409
+ layers.forEach(function (r, li) {
410
+ var lower = acc, upper = acc.map(function (a, i) { return a + r[i] }), c = colorOf(projects[li]); acc = upper
411
+ gradient(defs, 'sf' + li, 0, base, [[0, c, .95], [1, c, .55]])
412
+ var up = smooth(upper.map(function (v, i) { return [x(i), y(v)] })), low = smooth(lower.map(function (v, i) { return [x(i), y(v)] }).reverse())
413
+ shapes.push({ d: up + 'L' + low.slice(1) + 'Z', fill: 'url(#sf' + li + ')', top: up })
414
+ })
415
+ var last = shapes[shapes.length - 1]
416
+ svg('path', { d: last.top + 'L' + W + ',' + base + 'L0,' + base + 'Z', fill: '#5fe08a', filter: 'url(#sglow)', 'class': 'glow' }, box)
417
+ shapes.forEach(function (s) { svg('path', { d: s.d, fill: s.fill }, box) })
418
+ svg('path', { d: last.top, 'class': 'top-line', 'stroke-width': 1.2 }, box)
419
+ // One dot per session on the axis, at its hour of the day.
420
+ cur.forEach(function (t) {
421
+ var k = keys.indexOf(t.started.slice(0, 10)), hour = (+t.started.slice(11, 13) || 12) / 24
422
+ svg('circle', { cx: Math.min(W - 4, Math.max(4, x(k) + (hour - .5) * W / n)), cy: base + 22, r: 3.2, fill: colorOf(t.project) }, box)
423
+ })
424
+ var hover = svg('line', { y1: top - 12, y2: base, 'class': 'hover-line', visibility: 'hidden' }, box)
425
+ box.onmousemove = function (e) {
426
+ var r = box.getBoundingClientRect(), i = Math.max(0, Math.min(n - 1, Math.round((e.clientX - r.left) / r.width * (n - 1))))
427
+ hover.setAttribute('x1', x(i)); hover.setAttribute('x2', x(i)); hover.setAttribute('visibility', 'visible')
428
+ tip.textContent = ''; tip.append(h('div', 'tip-date', shortDate(keys[i])), h('div', 'tip-value', M.fmt(raw.reduce(function (a, rr) { return a + rr[i] }, 0))))
429
+ tip.style.left = x(i) / W * r.width + 'px'; tip.style.top = y(totals[i]) / H * r.height + 'px'; tip.hidden = false
430
+ }
431
+ box.onmouseleave = function () { hover.setAttribute('visibility', 'hidden'); tip.hidden = true }
432
+ }
433
+
434
+ function legend(shown) {
435
+ var box = byId('legend'); box.textContent = ''
436
+ if (shown.length < 2) return
437
+ shown.forEach(function (p) {
438
+ var b = h('button', 'chip'), d = h('span', 'dot'); b.type = 'button'; b.setAttribute('aria-pressed', String(!state.hidden[p])); d.style.setProperty('--c', colorOf(p))
439
+ b.append(d, document.createTextNode(p), h('span', 'x', state.hidden[p] ? '+' : '×'))
440
+ b.addEventListener('click', function () { state.hidden[p] = !state.hidden[p]; chart(); card() })
441
+ box.append(b)
442
+ })
443
+ }
444
+
445
+ function pill(text) {
446
+ var kind = /passed/.test(text) ? 'ok' : /failed/.test(text) ? 'bad' : /stale/.test(text) ? 'warn' : ''
447
+ var p = h('span', 'pill ' + kind); p.append(h('i'), document.createTextNode(testsText(text || 'not run'))); return p
448
+ }
449
+
450
+ function table() {
451
+ var body = byId('rows'), q = state.q.trim().toLowerCase(); body.textContent = ''
452
+ var list = inDays(scope(), days(span())).filter(function (t) { return !q || (t.name + ' ' + t.project + ' ' + modelName(t.model)).toLowerCase().indexOf(q) >= 0 })
453
+ .sort(function (a, b) { return b.started.localeCompare(a.started) })
454
+ byId('count').textContent = String(list.length)
455
+ if (!list.length) {
456
+ var tr = h('tr'), td = h('td', 'empty', q ? T.noMatch : tasks.length ? T.noPeriod : T.noSessions)
457
+ td.colSpan = 6; tr.append(td); body.append(tr); return
458
+ }
459
+ var max = Math.max.apply(null, list.map(function (t) { return t.agentMinutes })) || 1
460
+ list.forEach(function (t) {
461
+ var tr = h('tr'), name = h('td', 'name'), task = h('div', 'task', t.name || T.untitled), bar = h('div', 'bar'), tests = h('td')
462
+ task.title = t.name; bar.style.setProperty('--c', colorOf(t.project)); bar.style.width = Math.max(4, t.agentMinutes / max * 100) + '%'
463
+ name.append(task, h('div', 'sub', (state.project ? '' : t.project + ' · ') + shortDate(t.started.slice(0, 10)) + ', ' + t.started.slice(11) + (t.model ? ' · ' + modelName(t.model) : '')), bar)
464
+ // An imported session has no test record: a dash, not "not run".
465
+ tests.append(t.tests || t.level !== 'import' ? pill(t.tests) : h('span', 'sub', '–'))
466
+ tr.append(name, h('td', 'r num', time(t.agentMinutes * 60000)), h('td', 'r num', t.cost === null ? '–' : money(t.cost)), h('td', 'r num', tok(t.tokens)), h('td', 'r num', String(t.turns)), tests)
467
+ body.append(tr)
468
+ })
469
+ }
470
+
471
+ // Thermal ramp: a quiet indigo for a little agent time, through red to yellow for the most.
472
+ var HEAT = [[0, [58, 48, 120]], [.4, [150, 45, 112]], [.65, [235, 72, 58]], [.85, [255, 140, 60]], [1, [255, 214, 102]]]
473
+ function heatColor(a) {
474
+ for (var i = 1; i < HEAT.length; i++) if (a <= HEAT[i][0]) {
475
+ var lo = HEAT[i - 1], hi = HEAT[i], t = (a - lo[0]) / (hi[0] - lo[0])
476
+ return 'rgb(' + lo[1].map(function (c, j) { return Math.round(c + (hi[1][j] - c) * t) }).join(',') + ')'
477
+ }
478
+ return 'rgb(255,214,102)'
479
+ }
480
+ function hex(cx, cy, r) {
481
+ var d = ''
482
+ for (var k = 0; k < 6; k++) { var a = Math.PI / 3 * k - Math.PI / 2; d += (k ? 'L' : 'M') + (cx + r * Math.cos(a)).toFixed(1) + ',' + (cy + r * Math.sin(a)).toFixed(1) }
483
+ return d + 'Z'
484
+ }
485
+
486
+ // The last 12 weeks as a honeycomb: a column per week, a row per weekday, the colour is the day's agent time.
487
+ function heat() {
488
+ var s = byId('heat'), list = scope(), keys = days(84), vals = perDay(list, keys, METRICS.time.pick), max = Math.max.apply(null, vals.concat([0]))
489
+ var r = 17, w = Math.sqrt(3) * r, left = 44, top = r + 2, firstDow = new Date(now - 83 * DAY).getDay(), cols = Math.ceil((84 + firstDow) / 7); s.textContent = ''
490
+ blur(svg('defs', {}, s), 'hglow', 6)
491
+ var cells = keys.map(function (k, i) {
492
+ var pos = i + firstDow, row = pos % 7
493
+ return { k: k, v: vals[i], a: max ? vals[i] / max : 0, cx: left + Math.floor(pos / 7) * w + (row % 2 ? w / 2 : 0), cy: top + row * r * 1.5 }
494
+ })
495
+ cells.forEach(function (c) { if (c.a > .6) svg('path', { d: hex(c.cx, c.cy, r), fill: heatColor(c.a), filter: 'url(#hglow)', 'class': 'glow-cell' }, s) })
496
+ cells.forEach(function (c) {
497
+ var p = svg('path', c.v ? { d: hex(c.cx, c.cy, r - 2), fill: heatColor(c.a) } : { d: hex(c.cx, c.cy, r - 2), 'class': 'cell-empty' }, s)
498
+ svg('title', {}, p).textContent = shortDate(c.k) + ': ' + (c.v ? time(c.v) : T.noSession)
499
+ })
500
+ ;['2024-01-01', '2024-01-03', '2024-01-05'].map(function (k) { return dateText(k, { weekday: 'short' }) }).forEach(function (d, i) { svg('text', { x: 0, y: top + (1 + 2 * i) * r * 1.5 + 4, 'class': 'day' }, s).textContent = d })
501
+ // Legend: the ramp from less to more, under the right edge.
502
+ var right = left + cols * w + w / 2, ly = top + 6 * r * 1.5 + r + 20
503
+ var end = right - 40
504
+ svg('text', { x: end - 4 * 15 - 14, y: ly + 4, 'text-anchor': 'end', 'class': 'day' }, s).textContent = T.less
505
+ ;[.1, .3, .55, .8, 1].forEach(function (a, i) { svg('path', { d: hex(end - (4 - i) * 15, ly, 6.5), fill: heatColor(a) }, s) })
506
+ svg('text', { x: right, y: ly + 4, 'text-anchor': 'end', 'class': 'day' }, s).textContent = T.more
507
+ s.setAttribute('viewBox', '0 0 ' + Math.ceil(right + 2) + ' ' + Math.ceil(ly + 10))
508
+ // Two heroes from the same twelve weeks: on how many days agents worked, and the run of days up to today.
509
+ var active = vals.filter(function (v) { return v > 0 }).length, run = 0, longest = 0, streak = 0
510
+ vals.forEach(function (v) { run = v > 0 ? run + 1 : 0; longest = Math.max(longest, run) })
511
+ for (var j = vals[83] > 0 ? 83 : 82; j >= 0 && vals[j] > 0; j--) streak++
512
+ byId('h-active').textContent = String(active)
513
+ var share = byId('h-active-sub'); share.textContent = ''; share.append(h('b', '', Math.round(active / 84 * 100) + '%'), document.createTextNode(F(T.lastDays, { n: 84 })))
514
+ byId('h-streak').textContent = F(T.days, { n: streak })
515
+ byId('h-streak-sub').textContent = F(T.longest, { n: longest })
516
+ var cur = inDays(list, days(span())), byDay = {}, best = null
517
+ cur.forEach(function (t) { var k = t.started.slice(0, 10); byDay[k] = (byDay[k] || 0) + t.agentMinutes; if (!best || t.agentMinutes > best.agentMinutes) best = t })
518
+ var busiest = Object.keys(byDay).sort(function (a, b) { return byDay[b] - byDay[a] })[0], facts = byId('facts'); facts.textContent = ''
519
+ ;[[T.busiest, busiest ? shortDate(busiest) + ' · ' + time(byDay[busiest] * 60000) : '–'],
520
+ [T.longestSession, best ? time(best.agentMinutes * 60000) : '–'],
521
+ [T.avgSession, cur.length ? time(total(cur, METRICS.time.pick) / cur.length) : '–'],
522
+ [T.avgCost, priced(cur).length ? money(total(cur, METRICS.cost.pick) / priced(cur).length) : '–']].forEach(function (f) {
523
+ var r = h('div', 'fact'); r.append(h('span', '', f[0]), h('span', 'num', f[1])); facts.append(r)
524
+ })
525
+ }
526
+
527
+ // The share card: the numbers and the stream of what is on screen.
528
+ function card() {
529
+ var list = scope(), n = span(), keys = days(n), cur = inDays(list, keys).filter(function (t) { return !state.hidden[t.project] })
530
+ var projects = names.filter(function (p) { return cur.some(function (t) { return t.project === p }) })
531
+ byId('c-scope').textContent = (state.project || F(T.projectsN, { n: projects.length })) + ' · ' + (state.period ? F(T.lastDays, { n: n }) : T.allTime)
532
+ byId('c-time').textContent = time(total(cur, METRICS.time.pick))
533
+ byId('c-cost').textContent = show(METRICS.cost, cur)
534
+ byId('c-tokens').textContent = tok(total(cur, METRICS.tokens.pick))
535
+ byId('c-sessions').textContent = String(cur.length)
536
+ var g = byId('c-stream'), W = 1200, base = 600, topY = 380; g.textContent = ''
537
+ var layers = projects.map(function (p) { return perDay(cur.filter(function (t) { return t.project === p }), keys, METRICS.time.pick) })
538
+ var totals = keys.map(function (_, i) { return layers.reduce(function (a, r) { return a + r[i] }, 0) }), max = Math.max.apply(null, totals.concat([0]))
539
+ if (max <= 0) return
540
+ var x = function (i) { return n > 1 ? i * W / (n - 1) : W / 2 }, y = function (v) { return base - v / max * (base - topY) }, acc = keys.map(function () { return 0 }), shapes = []
541
+ layers.forEach(function (r, li) {
542
+ var lower = acc, upper = acc.map(function (a, i) { return a + r[i] }); acc = upper
543
+ var up = smooth(upper.map(function (v, i) { return [x(i), y(v)] })), low = smooth(lower.map(function (v, i) { return [x(i), y(v)] }).reverse())
544
+ shapes.push({ d: up + 'L' + low.slice(1) + 'Z', fill: 'url(#cf' + PALETTE.indexOf(colorOf(projects[li])) + ')', top: up })
545
+ })
546
+ svg('path', { d: shapes[shapes.length - 1].top + 'L' + W + ',' + base + 'L0,' + base + 'Z', fill: '#5fe08a', opacity: .18, filter: 'url(#cglow)' }, g)
547
+ shapes.forEach(function (s) { svg('path', { d: s.d, fill: s.fill }, g) })
548
+ }
549
+
550
+ function render() { sidebar(); header(); kpis(); compare(); chart(); table(); heat(); card() }
551
+
552
+ function download(blob, name) { var a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = name; a.click() }
553
+ // The saved card carries its own copy of the logo, so it stands alone.
554
+ function cardText() { var c = byId('card').cloneNode(true); c.querySelector('defs').append(byId('pt-logo').cloneNode(true)); return new XMLSerializer().serializeToString(c) }
555
+ function saveSvg() { download(new Blob([cardText()], { type: 'image/svg+xml' }), '2cmd-card.svg') }
556
+ function savePng() {
557
+ var img = new Image()
558
+ img.onload = function () {
559
+ try { var c = document.createElement('canvas'); c.width = 1200; c.height = 630; c.getContext('2d').drawImage(img, 0, 0); c.toBlob(function (b) { b ? download(b, '2cmd-card.png') : saveSvg() }) } catch (e) { saveSvg() }
560
+ }
561
+ img.onerror = saveSvg
562
+ img.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(cardText())
563
+ }
564
+
565
+ byId('q').addEventListener('input', function (e) { state.q = e.target.value; table() })
566
+ document.querySelectorAll('[data-metric]').forEach(function (b) {
567
+ b.addEventListener('click', function () { state.metric = b.getAttribute('data-metric'); document.querySelectorAll('[data-metric]').forEach(function (x) { x.classList.toggle('on', x === b) }); chart() })
568
+ })
569
+ document.querySelectorAll('[data-period]').forEach(function (b) {
570
+ b.addEventListener('click', function () { state.period = +b.getAttribute('data-period'); document.querySelectorAll('[data-period]').forEach(function (x) { x.classList.toggle('on', x === b) }); render() })
571
+ })
572
+ var resizing; window.addEventListener('resize', function () { clearTimeout(resizing); resizing = setTimeout(chart, 120) })
573
+ // Only for hosts without a settings page: the buttons are set by pasting a command, since this page cannot save anything.
574
+ if (D.panel) (function () {
575
+ var P = D.panel, rows = byId('btn-rows'), out = byId('btn-command'), note = byId('btn-note')
576
+ var KIND = { fix: T.btnFix, commit: T.btnCommit, push: T.btnPush, copy: T.btnCopy, review: T.btnReview, audit: T.btnAudit, tool: T.btnTool, prompt: T.btnCustom, none: T.btnNone }
577
+ // Every button shows a name and a command; a built-in one fills them in, and editing either makes it custom.
578
+ function preset(k) { return { name: P.labels[k] || '', text: P.texts[k] || '' } }
579
+ function draw(list) {
580
+ rows.textContent = ''
581
+ list.forEach(function (b, i) {
582
+ var row = h('div', 'btn-row'), select = h('select'), name = h('input'), text = h('input')
583
+ row.append(h('b', '', F(T.btnSlot, { n: i + 1 })), select, name, text)
584
+ P.kinds.forEach(function (k) { var o = h('option', '', KIND[k]); o.value = k; select.append(o) })
585
+ var first = b.kind === 'prompt' ? { name: b.label || '', text: b.text || '' } : preset(b.kind)
586
+ select.value = b.kind; name.value = first.name; text.value = first.text
587
+ name.maxLength = P.maxLabel; name.placeholder = T.btnName; text.placeholder = T.btnText
588
+ select.setAttribute('aria-label', F(T.btnSlot, { n: i + 1 })); name.setAttribute('aria-label', T.btnName); text.setAttribute('aria-label', T.btnText)
589
+ function lock() {
590
+ var k = select.value
591
+ name.disabled = k === 'copy' || k === 'none'; text.disabled = name.disabled
592
+ if (k === 'copy') { text.value = ''; text.placeholder = T.tipCopy } else text.placeholder = T.btnText
593
+ if (k === 'none') { name.value = ''; text.value = '' }
594
+ }
595
+ select.addEventListener('change', function () {
596
+ if (select.value !== 'prompt') { var p = preset(select.value); name.value = p.name; text.value = p.text }
597
+ lock(); update()
598
+ })
599
+ function edited() {
600
+ var k = select.value, p = preset(k)
601
+ if (k !== 'prompt' && k in P.texts && (name.value !== p.name || text.value !== p.text)) select.value = 'prompt'
602
+ update()
603
+ }
604
+ name.addEventListener('input', edited); text.addEventListener('input', edited)
605
+ rows.append(row); lock()
606
+ })
607
+ update()
608
+ }
609
+ function read() {
610
+ return Array.prototype.map.call(rows.children, function (row) {
611
+ var k = row.querySelector('select').value, f = row.querySelectorAll('input')
612
+ return k === 'prompt' ? { kind: k, label: f[0].value.trim(), text: f[1].value.trim() } : { kind: k }
613
+ })
614
+ }
615
+ function update() {
616
+ var list = read(), ok = list.every(function (b) { return b.kind !== 'prompt' || (b.label && Array.from(b.label).length <= P.maxLabel && b.text) })
617
+ out.value = ok ? '/2cmd-buttons ' + JSON.stringify(list) : ''
618
+ note.textContent = ok ? T.btnHow : T.btnInvalid
619
+ byId('btn-ok').disabled = !ok
620
+ }
621
+ function toast(text) {
622
+ var t = h('div', 'toast', text); t.setAttribute('role', 'status'); document.body.append(t)
623
+ setTimeout(function () { t.remove() }, 6000)
624
+ }
625
+ byId('btn-open').addEventListener('click', function () { draw(P.buttons); byId('btn-dialog').showModal() })
626
+ byId('btn-close').addEventListener('click', function () { byId('btn-dialog').close() })
627
+ byId('btn-reset').addEventListener('click', function () { draw(P.defaults) })
628
+ // OK copies the command and closes; the page cannot save, so the person pastes the command into the host.
629
+ byId('btn-ok').addEventListener('click', function () {
630
+ function done() { byId('btn-dialog').close(); toast(T.btnDone) }
631
+ out.select()
632
+ if (navigator.clipboard) navigator.clipboard.writeText(out.value).then(done, function () { document.execCommand('copy') && done() })
633
+ else if (document.execCommand('copy')) done()
634
+ })
635
+ })()
636
+ byId('share').addEventListener('click', function () { byId('share-dialog').showModal() })
637
+ byId('share-close').addEventListener('click', function () { byId('share-dialog').close() })
638
+ byId('save-png').addEventListener('click', savePng)
639
+ byId('save-svg').addEventListener('click', saveSvg)
640
+ var THEMES = ['dark', 'light', 'system'], THEME_NAMES = { dark: T.dark, light: T.light, system: T.system }
641
+ function applyTheme(choice) {
642
+ document.documentElement.setAttribute('data-theme', choice)
643
+ var b = byId('theme'), next = THEMES[(THEMES.indexOf(choice) + 1) % THEMES.length]
644
+ b.setAttribute('data-choice', choice)
645
+ b.setAttribute('aria-label', F(T.theme, { a: THEME_NAMES[choice] }) + ', ' + F(T.switchTo, { a: THEME_NAMES[next] }))
646
+ b.title = F(T.theme, { a: THEME_NAMES[choice] })
647
+ }
648
+ var saved = 'dark'
649
+ try { saved = localStorage.getItem('2cmd-board-theme') || 'dark' } catch (e) {}
650
+ applyTheme(THEMES.indexOf(saved) >= 0 ? saved : 'dark')
651
+ byId('theme').addEventListener('click', function () {
652
+ var next = THEMES[(THEMES.indexOf(byId('theme').getAttribute('data-choice')) + 1) % THEMES.length]
653
+ applyTheme(next)
654
+ try { localStorage.setItem('2cmd-board-theme', next) } catch (e) {}
655
+ })
656
+
657
+ render()
658
+ })()`
659
+
660
+ // The share card stays dark in both themes: an image for X or LinkedIn, not part of the page's look.
661
+ // The page fills its numbers and stream; the logo symbol joins it when the card is saved.
662
+ const SANS = "Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei UI', 'Microsoft YaHei', Roboto, sans-serif"
663
+ const MONO = "'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, 'Cascadia Mono', Consolas, monospace"
664
+ const cardStat = (y: number, label: string, id: string) =>
665
+ `<text x="760" y="${y}" font-size="20" fill="#8d8b84">${label}</text><text id="${id}" x="1128" y="${y}" text-anchor="end" font-family="${MONO}" font-size="30" fill="#f3f2ee"></text>`
666
+ const card = (t: Strings) => `<svg id="card" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 630" width="1200" height="630" font-family="${SANS}">
667
+ <defs>${PALETTE.map((c, i) => `<linearGradient id="cf${i}" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${c}" stop-opacity=".95"/><stop offset="1" stop-color="${c}" stop-opacity=".55"/></linearGradient>`).join('')}<filter id="cglow" x="-20%" y="-50%" width="140%" height="200%"><feGaussianBlur stdDeviation="12"/></filter><radialGradient id="chalo" cx=".62" cy=".8" r=".6"><stop offset="0" stop-color="#5fe08a" stop-opacity=".16"/><stop offset="1" stop-color="#5fe08a" stop-opacity="0"/></radialGradient></defs>
668
+ <rect width="1200" height="630" fill="#070707"/><rect width="1200" height="630" fill="url(#chalo)"/>
669
+ <g id="c-stream"></g><rect y="600" width="1200" height="30" fill="#070707"/>
670
+ <use href="#pt-logo" x="72" y="64" width="48" height="48"/>
671
+ <text x="134" y="98" font-family="${MONO}" font-size="28" font-weight="600" fill="#f3f2ee">2Cmd</text>
672
+ <text id="c-scope" x="1128" y="98" text-anchor="end" font-size="20" fill="#8d8b84"></text>
673
+ <text x="72" y="196" font-size="22" fill="#8d8b84">${esc(t.time)}</text><text id="c-time" x="66" y="292" font-family="${MONO}" font-size="104" font-weight="600" letter-spacing="-5" fill="#f3f2ee"></text>
674
+ ${cardStat(172, esc(t.cost), 'c-cost')}${cardStat(228, esc(t.tokens), 'c-tokens')}${cardStat(284, esc(t.sessions), 'c-sessions')}
675
+ <text x="72" y="621" font-family="${MONO}" font-size="15" fill="#5e5c55">${esc(t.measured)}</text><text x="1128" y="621" text-anchor="end" font-family="${MONO}" font-size="15" fill="#5fe08a">2cmd.dev</text></svg>`
676
+
677
+ // JSON inside a script block: "<" is escaped so no name can close the block.
678
+ const json = (value: unknown) => JSON.stringify(value).replace(/</g, '\\u003c').replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029')
679
+
680
+ // Dark, light, system: CSS shows the icon of the current choice.
681
+ const THEME_BUTTON = '<button type="button" class="theme" id="theme" data-choice="dark"><svg class="i-system" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg><svg class="i-light" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg><svg class="i-dark" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg></button>'
682
+
683
+ // The tab icon.
684
+ const FAVICON = `data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${LOGO_VIEWBOX}">${LOGO_PATHS}</svg>`)}`
685
+
686
+ const SEARCH_ICON = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>'
687
+
688
+ export function boardHtml(tasks: Task[], now: number, { lang, t }: Pick<Locale, 'lang' | 't'>, currency?: string, panel?: { host: Host; buttons: PanelButton[] }): string {
689
+ const settings = panel && { ...panel, kinds: buttonKinds(panel.host), defaults: DEFAULT_BUTTONS, maxLabel: MAX_LABEL, labels: { fix: t.reviewFix, commit: t.reviewCommit, push: t.reviewPush, copy: t.copy, review: t.review, audit: t.audit, tool: t.toolReview }, texts: COMMANDS[panel.host] }
690
+ const days = (n: number) => fill(t.days, { n })
691
+ // For all projects ('') and for each one: the sidebar picks which one shows.
692
+ const compare = Object.fromEntries(['', ...new Set(tasks.map(x => x.project))].map(p => [p, compareModes(p ? tasks.filter(x => x.project === p) : tasks)]))
693
+ const seg = (attr: string, items: [string, string][], on: string) =>
694
+ items.map(([value, label]) => `<button type="button" data-${attr}="${value}"${value === on ? ' class="on"' : ''}>${label}</button>`).join('')
695
+ return `<!doctype html><html lang="${lang}" data-theme="dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>2Cmd · ${esc(t.board)}</title><link rel="icon" href="${FAVICON}"><style>${CSS}</style></head>
696
+ <body><svg class="sprite" aria-hidden="true" focusable="false"><symbol id="pt-logo" viewBox="${LOGO_VIEWBOX}">${LOGO_PATHS}</symbol></svg>
697
+ <div class="app">
698
+ <aside class="side"><div class="brand"><span class="logo"><svg viewBox="${LOGO_VIEWBOX}" aria-hidden="true"><use href="#pt-logo"/></svg></span>2Cmd</div><div class="side-label">${esc(t.projects)}</div><nav id="projects"></nav><div class="side-foot">${settings ? `<button type="button" class="nav-item" id="btn-open">${esc(t.btnTitle)}</button>` : ''}${THEME_BUTTON}</div></aside>
699
+ <main>
700
+ <div class="top"><div><div class="crumb">${esc(t.board)} / <b id="crumb"></b></div><h1 id="title"></h1><p id="subtitle"></p></div>
701
+ <div class="actions"><div class="seg" role="group" aria-label="${esc(t.period)}">${seg('period', [['7', esc(days(7))], ['30', esc(days(30))], ['90', esc(days(90))], ['0', esc(t.all)]], '30')}</div><button type="button" class="btn" id="share">${esc(t.share)}</button></div></div>
702
+ <section class="kpis" id="kpis"></section>
703
+ <section class="card cmp-card" id="compare"></section>
704
+ <section class="card chart-card"><div class="chart-head"><div><div class="label" id="chart-sub"></div><div class="big num" id="chart-total"></div></div>
705
+ <div class="seg" role="group" aria-label="${esc(t.metric)}">${seg('metric', [['time', esc(t.time)], ['cost', esc(t.cost)], ['tokens', esc(t.tokens)]], 'time')}</div></div>
706
+ <div class="chart-wrap"><svg id="stream" role="img" aria-label="${esc(t.perDay)}"></svg><div class="tip" id="tip" hidden></div></div><div class="legend" id="legend"></div></section>
707
+ <div class="grid2">
708
+ <section class="card list"><div class="list-head"><h3>${esc(t.sessions)}<span class="n" id="count"></span></h3><label class="search">${SEARCH_ICON}<input id="q" type="search" placeholder="${esc(t.search)}" aria-label="${esc(t.search)}"></label></div>
709
+ <div class="table-wrap"><table><thead><tr><th>${esc(t.session)}</th><th class="r">${esc(t.time)}</th><th class="r">${esc(t.cost)}</th><th class="r">${esc(t.tokens)}</th><th class="r">${esc(t.turns)}</th><th>${esc(t.tests)}</th></tr></thead><tbody id="rows"></tbody></table></div></section>
710
+ <section class="card heat"><h3>${esc(t.activity)}</h3><div class="sub">${esc(t.activity12)}</div><svg id="heat" role="img" aria-label="${esc(t.activity12)}"></svg>
711
+ <div class="heroes"><div><div class="hero-label"><i style="color:#5fe08a">✦</i>${esc(t.activeDays)}</div><div class="hero-value num" id="h-active"></div><div class="hero-sub" id="h-active-sub"></div></div>
712
+ <div><div class="hero-label"><i style="color:#ffd166">◆</i>${esc(t.streak)}</div><div class="hero-value num" id="h-streak"></div><div class="hero-sub" id="h-streak-sub"></div></div></div><div id="facts"></div></section>
713
+ </div>
714
+ <footer>${esc(t.footer)}</footer>
715
+ </main></div>
716
+ <dialog id="share-dialog"><div class="dlg-head"><b>${esc(t.share)}</b><div class="dlg-actions"><button type="button" class="btn" id="save-png">${esc(t.savePng)}</button><button type="button" class="btn" id="save-svg">${esc(t.saveSvg)}</button><button type="button" class="btn" id="share-close">${esc(t.close)}</button></div></div><div class="dlg-body">${card(t)}</div></dialog>
717
+ ${settings ? `<dialog id="btn-dialog" aria-label="${esc(t.btnTitle)}"><div class="dlg-head"><b>${esc(t.btnTitle)}</b><div class="dlg-actions"><button type="button" class="btn" id="btn-reset">${esc(t.btnReset)}</button><button type="button" class="btn" id="btn-close">${esc(t.close)}</button></div></div><div class="dlg-body"><p class="btn-help">${esc(t.btnNote)}</p><div class="btn-head"><span></span><span>${esc(t.btnKind)}</span><span>${esc(t.btnName)}</span><span>${esc(t.btnText)}</span></div><div id="btn-rows"></div><textarea id="btn-command" readonly rows="2" aria-label="${esc(t.btnCommand)}"></textarea><div class="btn-foot"><span id="btn-note" role="status"></span><button type="button" class="btn primary" id="btn-ok">${esc(t.btnConfirm)}</button></div></div></dialog>` : ''}
718
+ <script type="application/json" id="board-data">${json({ now, tasks, lang, t, currency, panel: settings, compare, compareMin: COMPARE_MIN })}</script>
719
+ <script>${APP}</script></body></html>`
720
+ }