@jjanczur/tyran 0.1.11 → 0.1.13

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.
@@ -11,7 +11,7 @@
11
11
  {
12
12
  "name": "tyran",
13
13
  "description": "A task conductor for Claude Code: multi-agent orchestration with an enforced evidence contract, repo-specific learning, and update-safe local evolution.",
14
- "version": "0.1.11",
14
+ "version": "0.1.13",
15
15
  "source": "./",
16
16
  "author": {
17
17
  "name": "Jacek Janczura",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tyran",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "A task conductor for Claude Code: multi-agent orchestration with an enforced evidence contract, repo-specific learning, and update-safe local evolution.",
5
5
  "author": {
6
6
  "name": "Jacek Janczura",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.13 — 2026-08-13
4
+
5
+ ### Six concurrent decisions, two ids
6
+
7
+ `append` took the write lock; issuing the `D-<n>` or `F-<n>` a caller omitted
8
+ happened before it, in the CLI. Issuing an id is read-compute-write, so every
9
+ concurrent writer read the same journal, computed the same next number, and
10
+ then serialized on the lock to write it. Measured on a fresh journal, seven
11
+ runs of six simultaneous `decision` appends: **1 to 4 distinct ids for 6
12
+ events**, and in the worst run all six carried the same id. Ids are how the
13
+ ledger references itself — "see D-2" —
14
+ in a file that is never rewritten, so every collision is ambiguous
15
+ permanently: neither `validate` nor the projections can say which `D-2` a
16
+ later event meant, and the premise of the whole design is many agents writing
17
+ one ledger at once.
18
+
19
+ The id is now issued inside the lock, from the snapshot that call has already
20
+ read for the timestamp clamp and the spawn guard — no second read per append,
21
+ which a long journal would pay for on every event. The contract is unchanged:
22
+ an explicit `data.id` still wins, `"id":""` is still treated as absent, and
23
+ only `decision` and `finding` are issued one. The same six-process race now
24
+ measures 6 distinct ids for 6 events, and eight genuinely concurrent
25
+ processes pin it in the suite.
26
+
27
+ The exported `append()` moved with the CLI, not behind it: before this release
28
+ a `decision` without `data.id` was rejected outright — `invalid event: data.id
29
+ is required for ev "decision"` — so every programmatic caller had to compute an
30
+ id first and then carry it across exactly the gap this release closes. Omitting
31
+ `data.id` is now the safe call rather than an error.
32
+
33
+ What is atomic is exactly the ids `append` ISSUES — `decision` and `finding`,
34
+ where `data.id` was omitted or empty: two of those, concurrent, can no longer
35
+ be handed one number. Nothing else moved. `next-id` previews a value while
36
+ holding nothing, so an id read there and appended later still loses to any
37
+ writer that appended in between — both journal doc surfaces say so, and a
38
+ caller that can let `append` issue the id should. An explicit `data.id` is
39
+ written verbatim and stays the caller's to keep unique: a journal whose three
40
+ `decision` events all carry `D-2` validates `ok`. `ticket.created` is
41
+ deliberately outside the issued set — a ticket id comes from the plan, which
42
+ numbers its own stories — so there is no atomic path for a `T-` id at all, and
43
+ `skills/run/SKILL.md` now says the conductor is the single writer for ticket
44
+ creation. And an id at or past 2^53 saturates `max+1`: seeded with
45
+ `D-9007199254740992`, `append` issues that same number to every decision after
46
+ it, and a 400-digit id yields `D-Infinity` — arithmetic byte-identical to the
47
+ previous release, named here rather than changed here.
48
+ ## 0.1.12 — 2026-08-13
49
+
50
+ ### The board: every ticket in a lane, every question in front of you
51
+
52
+ The read-only dashboard the roadmap promised, built the only way this state
53
+ layer allows: as a projection. `BOARD.md`/`board.json` render next to every
54
+ journal with the other projections; `scripts/board.mjs` folds every
55
+ initiative into one `.tyran/state/BOARD.md`, `board.json` (schema 1) and
56
+ `board.html` — a self-contained page in the landing page's own stone/gold/
57
+ glow palette that refreshes itself, puts the waiting-on-you queue first
58
+ (question, recommendation, default), lights the agent strip with each
59
+ agent's own last signal, and computes ages in the browser so the artefact
60
+ itself stays clock-free and byte-checkable. `--serve` adds a loopback-only
61
+ always-fresh viewer.
62
+
63
+ Lanes derive strongest-verdict-first from events that already exist —
64
+ `merge`, reviews, reports, running spawns, dep satisfaction (an unknown dep
65
+ refuses to schedule), blockages, `ticket.status` overrides, operator asks
66
+ (`WAITING_ON_OPERATOR` gates; `answered` joins the pass set), and the
67
+ overnight pause. A `SubagentStop` probe re-renders after every agent, with
68
+ the CLI's own damaged-journal refusal mirrored so an empty render never
69
+ clobbers good state; doctor gains `board-absent` (info) and drift coverage
70
+ for the new pair; an unreadable initiative is a visible UNREADABLE entry.
71
+
3
72
  ## 0.1.11 — 2026-08-13
4
73
 
5
74
  ### The journal learns what agents are doing, finding, and waiting on
package/README.md CHANGED
@@ -343,7 +343,7 @@ Tyran does, and that is the point of the "small curated core" row above —
343
343
  oh-my-claudecode's own issue #2943 is titled "50+ skills exceeding context
344
344
  description budget", which is the bill that arrives with the larger number.
345
345
  Tyran's fourteen are held under a description budget CI enforces on every
346
- push (4340 of 5000 characters, and a test fails if this sentence and the
346
+ push (4352 of 5000 characters, and a test fails if this sentence and the
347
347
  script ever disagree). That ceiling was 4000 for the first eight skills and
348
348
  was raised once, deliberately, with the reason in the changelog — the
349
349
  distinction being that #2943 describes a budget that was <i>exceeded</i>, and
@@ -359,7 +359,7 @@ Published on npm as [`@jjanczur/tyran`](https://www.npmjs.com/package/@jjanczur/
359
359
  command stays `tyran` either way; only the registry name is scoped, the same
360
360
  pattern as `@angular/cli` giving you `ng`. `bin/tyran.mjs` exposes the same
361
361
  scripts the plugin's hooks and skills already call — `doctor`, `scan-repo`,
362
- `tiers`, `journal`, `schema`, `knowledge`, `stop-check`,
362
+ `tiers`, `journal`, `schema`, `knowledge`, `board`, `overnight`, `statusline`, `stop-check`,
363
363
  `scan-control-chars`, `desc-budget` — for a shell or a CI job with no Claude
364
364
  Code session. Zero dependencies; `--help` lists them.
365
365
 
@@ -440,7 +440,9 @@ underlying script does.
440
440
  telemetry sidecar, a wind-down gate near the subscription window, and a
441
441
  watcher that resumes (or, on a days-away weekly reset, notifies and
442
442
  holds) — see [docs/overnight.md](docs/overnight.md)
443
- - [ ] Read-only dashboard (phase C)
443
+ - [x] Read-only dashboard: the kanban board — `BOARD.md`/`board.json` next to
444
+ every journal, one cross-initiative `board.html` in the landing page's
445
+ own palette, refreshed on every subagent stop, plus `board.mjs --serve`
444
446
 
445
447
  ## Where this came from
446
448
 
package/bin/tyran.mjs CHANGED
@@ -80,6 +80,10 @@ export const COMMANDS = {
80
80
  'statusline.mjs',
81
81
  'Statusline helper that tees platform rate-limit telemetry into .tyran/state/usage.json for the usage gate.',
82
82
  ],
83
+ board: [
84
+ 'board.mjs',
85
+ 'Render the cross-initiative kanban board — BOARD.md, board.json and the board.html dashboard — from the journals under .tyran/state/.',
86
+ ],
83
87
  'stop-check': [
84
88
  'stop-check.mjs',
85
89
  'Check the .tyran/STOP operator brake that halts a running initiative before its next spawn or merge.',
package/hooks/hooks.json CHANGED
@@ -75,6 +75,16 @@
75
75
  "timeout": 20
76
76
  }
77
77
  ]
78
+ },
79
+ {
80
+ "matcher": ".+|^$",
81
+ "hooks": [
82
+ {
83
+ "type": "command",
84
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/board-refresh.mjs\"",
85
+ "timeout": 12
86
+ }
87
+ ]
78
88
  }
79
89
  ],
80
90
  "PreCompact": [
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * board-refresh — the board is fresh after every agent, without anyone
4
+ * remembering to regenerate it.
5
+ *
6
+ * A SubagentStop PROBE, deliberately separate from the evidence gate that
7
+ * shares the event: a gate's output channel is a refusal channel, and a
8
+ * render failure must never refuse a report — while the evidence gate's own
9
+ * header refuses to drag the projection module into a gate's startup. Probes
10
+ * fail open by construction (`runProbe`); every failure here degrades to
11
+ * silence and the next merge re-renders anyway.
12
+ *
13
+ * Interleaving note: the evidence gate may append its `gate` event
14
+ * concurrently with this render. The journal's write lock serializes the
15
+ * writers; this probe may therefore render the pre-event state, which the
16
+ * next stop or merge corrects. A board is a projection, not a ledger.
17
+ */
18
+ import { existsSync } from 'node:fs';
19
+ import { join, resolve } from 'node:path';
20
+ import { realpathSync } from 'node:fs';
21
+ import { fileURLToPath } from 'node:url';
22
+ import { resolveRepoRoot } from './session-start.mjs';
23
+ import { main, runProbe } from './hook-io.mjs';
24
+
25
+ export const DEADLINE_MS = 6000;
26
+
27
+ export async function refresh(input) {
28
+ const repoRoot = resolveRepoRoot(input);
29
+ if (repoRoot === null) return {};
30
+ const tyranDir = join(repoRoot, '.tyran');
31
+ if (!existsSync(join(tyranDir, 'state'))) return {};
32
+ try {
33
+ // Dynamic imports on purpose: nothing heavy loads before we know there is
34
+ // a state directory to render.
35
+ const [{ readdirSync, statSync }, projectModule, boardModule] = await Promise.all([
36
+ import('node:fs'),
37
+ import('../../scripts/project.mjs'),
38
+ import('../../scripts/board.mjs'),
39
+ ]);
40
+ const stateDir = join(tyranDir, 'state');
41
+ for (const name of readdirSync(stateDir).sort()) {
42
+ const dir = join(stateDir, name);
43
+ try {
44
+ if (!statSync(dir).isDirectory()) continue;
45
+ const journal = join(dir, 'journal.jsonl');
46
+ if (!existsSync(journal)) continue;
47
+ const { files, state } = projectModule.projectFile(journal);
48
+ // The CLI's own refusal guard, mirrored: a journal with zero readable
49
+ // events and damage renders an EMPTY board — writing that over good
50
+ // projections would erase state exactly when the journal needs help.
51
+ if (state.total === 0 && (state.corruptLines + state.malformed > 0 || state.truncatedTail)) continue;
52
+ projectModule.writeAllAtomic(Object.entries(files).map(([f, content]) => [join(dir, f), content]));
53
+ } catch {
54
+ /* one broken initiative must not stop the rest */
55
+ }
56
+ }
57
+ const rendered = boardModule.renderAll(tyranDir);
58
+ projectModule.writeAllAtomic(
59
+ Object.entries(rendered.files).map(([name, content]) => [join(stateDir, name), content]),
60
+ );
61
+ } catch {
62
+ /* a probe never speaks about its own failure; doctor reports staleness */
63
+ }
64
+ return {};
65
+ }
66
+
67
+ function canonicalPath(path) {
68
+ const abs = resolve(path);
69
+ try {
70
+ return realpathSync(abs);
71
+ } catch {
72
+ return abs;
73
+ }
74
+ }
75
+
76
+ function isMainModule(moduleUrl) {
77
+ if (!process.argv[1]) return false;
78
+ return canonicalPath(process.argv[1]) === canonicalPath(fileURLToPath(moduleUrl));
79
+ }
80
+
81
+ if (isMainModule(import.meta.url)) {
82
+ await main(() =>
83
+ runProbe({
84
+ event: 'SubagentStop',
85
+ deadlineMs: DEADLINE_MS,
86
+ handler: ({ input }) => refresh(input),
87
+ }),
88
+ );
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jjanczur/tyran",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Command-line scripts for the Tyran task conductor (doctor, journal, schema, and repo tooling) for CI and terminals outside Claude Code. Installing this package does NOT install the Claude Code plugin — add that separately with `/plugin marketplace add jjanczur/tyran` inside Claude Code.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env node
2
+ import { FORBIDDEN } from './invisible.mjs';
3
+ /**
4
+ * board-html — the one page an operator stares at overnight.
5
+ *
6
+ * Renders the cross-initiative board payload (see board.mjs) as a single
7
+ * self-contained HTML file: inline CSS, inline JS, no network requests, works
8
+ * over file://. A <meta refresh> keeps it current — fetch() of a sibling file
9
+ * is blocked over file:// in Chromium, so meta-refresh is the one reliable
10
+ * primitive; under `board.mjs --serve` the same refresh hits the server.
11
+ *
12
+ * ## Style: the landing page's system, not a new one
13
+ *
14
+ * Tokens are copied from `site/src/styles/landing.css` (operator-decided
15
+ * 2026-08-14): the stone/gold/glow palette read off the banner, system font
16
+ * stacks (no web fonts), dark only. The semantic mapping keeps the landing's
17
+ * own rules — gold is the ONE accent, so it marks the operator's waiting
18
+ * queue (the page's only call to action); the glow is a light source, so it
19
+ * lights the agent strip (literally the cold light off the agents' screens);
20
+ * red stays refusal (the PAUSED banner, the blocked lane); green stays the
21
+ * ledger `+` (the done lane).
22
+ *
23
+ * ## Safety
24
+ *
25
+ * Three layers, each pinned by a test that fails with the layer removed:
26
+ * board.json is already invisible-escaped (`jsonEscapeInvisible`); the JSON
27
+ * embedded in the page additionally escapes `<` as < so a journal value
28
+ * containing `</script>` cannot break out; and the client renders with
29
+ * createElement/textContent ONLY — no innerHTML anywhere.
30
+ *
31
+ * Determinism: the page shows "as of <newest event ts>", never the wall
32
+ * clock, so `--check` covers board.html byte-for-byte. Ages in the agent
33
+ * strip are computed client-side from Date.now() — the one place a clock is
34
+ * allowed, because it runs in the viewer's browser, not in the artifact.
35
+ */
36
+
37
+ const CSS = `
38
+ :root{
39
+ --bg:#12100e;--bg-raised:#1c1917;--bg-sunken:#0d0c0a;
40
+ --text:#d9d2c6;--heading:#f5efe3;--muted:#a29788;
41
+ --hairline:#3b342c;--hairline-soft:#29241f;
42
+ --gold:#d4a017;--gold-bright:#e8bc4d;--gold-low:#2a2110;
43
+ --glow:#8fd8ea;--glow-dim:#1e3a44;
44
+ --red:#f2665e;--red-low:#35191a;--green:#8fce6a;
45
+ --display:ui-serif,'Iowan Old Style','Palatino Linotype',Palatino,'Book Antiqua',Georgia,'Times New Roman',serif;
46
+ --font:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;
47
+ --mono:ui-monospace,SFMono-Regular,'SF Mono',Menlo,Consolas,'Liberation Mono',monospace;
48
+ --radius:0.75rem;color-scheme:dark;
49
+ }
50
+ *{box-sizing:border-box}
51
+ body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font);font-size:1rem;line-height:1.55;-webkit-font-smoothing:antialiased;padding:1.25rem}
52
+ main{max-width:68rem;margin:0 auto}
53
+ h1{font-family:var(--display);color:var(--heading);font-size:1.6rem;margin:0 0 .25rem}
54
+ h2{font-family:var(--display);color:var(--heading);font-size:1.05rem;margin:1.5rem 0 .5rem;border-bottom:1px solid var(--hairline-soft);padding-bottom:.3rem}
55
+ .meta{color:var(--muted);font-family:var(--mono);font-size:.8rem}
56
+ .paused{background:var(--red-low);border:1px solid var(--red);color:var(--red);border-radius:var(--radius);padding:.6rem .9rem;margin:.9rem 0;font-weight:600}
57
+ .ask{background:var(--gold-low);border:1px solid var(--gold);border-radius:var(--radius);padding:.7rem .9rem;margin:.5rem 0}
58
+ .ask .q{color:var(--gold-bright);font-size:1.05rem;font-weight:600}
59
+ .ask .row{margin-top:.25rem;font-size:.9rem}
60
+ .ask .label{color:var(--muted);text-transform:uppercase;font-size:.7rem;letter-spacing:.06em;margin-right:.4rem}
61
+ .agents{display:flex;flex-wrap:wrap;gap:.5rem}
62
+ .agent{background:var(--bg-raised);border:1px solid var(--glow-dim);border-left:3px solid var(--glow);border-radius:var(--radius);padding:.45rem .7rem;font-family:var(--mono);font-size:.8rem;min-width:14rem}
63
+ .agent .name{color:var(--glow);font-weight:600}
64
+ .agent .age-fresh{color:var(--green)}
65
+ .agent .age-warm{color:var(--gold-bright)}
66
+ .agent .age-cold{color:var(--red)}
67
+ .lanes{display:grid;grid-template-columns:repeat(auto-fill,minmax(15rem,1fr));gap:.7rem;align-items:start}
68
+ .lane{background:var(--bg-sunken);border:1px solid var(--hairline-soft);border-radius:var(--radius);padding:.6rem}
69
+ .lane h3{margin:0 0 .4rem;font-size:.8rem;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}
70
+ .lane h3 .count{color:var(--text)}
71
+ .lane.blocked{border-color:var(--red)}
72
+ .lane.blocked h3 .count{color:var(--red)}
73
+ .lane.done h3 .count{color:var(--green)}
74
+ .lane.waiting-operator{border-color:var(--gold-dim, #6d5410)}
75
+ .card{background:var(--bg-raised);border:1px solid var(--hairline);border-radius:.5rem;padding:.4rem .55rem;margin:.3rem 0;font-size:.85rem}
76
+ .card .id{font-family:var(--mono);color:var(--heading)}
77
+ .card .init{font-family:var(--mono);color:var(--muted);font-size:.7rem}
78
+ .card .note{color:var(--muted);font-size:.78rem;display:block}
79
+ .empty{color:var(--hairline);font-size:.8rem}
80
+ footer{margin-top:2rem;color:var(--muted);font-size:.75rem;border-top:1px solid var(--hairline-soft);padding-top:.6rem}
81
+ `;
82
+
83
+ /**
84
+ * The FORBIDDEN ranges as a regex character class, generated rather than
85
+ * retyped: this is the same question `escapeInvisible` answers, and ADR-21
86
+ * gives it one answer. Emitted as `\u{...}` escapes so this file's own bytes
87
+ * stay ASCII — writing the characters themselves is what the write guard
88
+ * refuses, and it refused this very edit once.
89
+ */
90
+ const CLIENT_INVISIBLE_CLASS = FORBIDDEN.map(({ lo, hi }) => {
91
+ const cp = (n) => `\\u{${n.toString(16).toUpperCase()}}`;
92
+ return lo === hi ? cp(lo) : `${cp(lo)}-${cp(hi)}`;
93
+ }).join('');
94
+
95
+ const CLIENT_JS = `
96
+ 'use strict';
97
+ var data = JSON.parse(document.getElementById('board-data').textContent);
98
+ if (data.schema !== 1) {
99
+ document.getElementById('app').textContent = 'This board.json is schema ' + data.schema + ' — regenerate with a newer Tyran.';
100
+ } else {
101
+ // board.json's escaping is LOSSLESS — JSON.parse hands the browser the
102
+ // original codepoints back — so the page is where invisibles must be
103
+ // neutralised. They cannot inject (textContent never parses markup), but an
104
+ // unterminated right-to-left override mirrors every character after it and
105
+ // rewrites the page a human is reading, and TAG characters map one-to-one
106
+ // onto ASCII while rendering as nothing. Escaped, never dropped: a value the
107
+ // operator cannot see is a value they cannot judge.
108
+ var INVISIBLE = new RegExp('[${CLIENT_INVISIBLE_CLASS}]', 'gu');
109
+ var show = function (value) {
110
+ return String(value).replace(INVISIBLE, function (ch) {
111
+ return '\\\\u' + ch.codePointAt(0).toString(16).toUpperCase();
112
+ });
113
+ };
114
+ var el = function (tag, cls, text) {
115
+ var node = document.createElement(tag);
116
+ if (cls) node.className = cls;
117
+ if (text !== undefined && text !== null) node.textContent = show(text);
118
+ return node;
119
+ };
120
+ var app = document.getElementById('app');
121
+ var head = el('div');
122
+ head.appendChild(el('h1', null, 'Tyran board'));
123
+ var totals = data.totals || {};
124
+ head.appendChild(el('div', 'meta',
125
+ (totals.agents || 0) + ' agent(s) running across ' + (totals.initiatives || 0) + ' initiative(s) · ' +
126
+ (totals.merged || 0) + '/' + (totals.tickets || 0) + ' tickets merged (' + (totals.percent || 0) + '%) · as of ' + (data.as_of || 'unknown')));
127
+ app.appendChild(head);
128
+
129
+ (data.paused || []).forEach(function (p) {
130
+ app.appendChild(el('div', 'paused', 'PAUSED — ' + p.init + ': gate ' + p.kind + ' (' + p.result + ') since ' + p.since));
131
+ });
132
+
133
+ var asks = data.asks || [];
134
+ app.appendChild(el('h2', null, 'Waiting on you (' + asks.length + ')'));
135
+ if (asks.length === 0) app.appendChild(el('div', 'empty', 'nothing — the agents have what they need'));
136
+ asks.forEach(function (a) {
137
+ var card = el('div', 'ask');
138
+ card.appendChild(el('div', 'q', a.question || '(no question recorded — gate ' + a.kind + ')'));
139
+ [['recommendation', a.recommendation], ['default', a.default],
140
+ ['ticket', a.ticket], ['initiative', a.init], ['since', a.since]].forEach(function (pair) {
141
+ if (pair[1] === null || pair[1] === undefined) return;
142
+ var row = el('div', 'row');
143
+ row.appendChild(el('span', 'label', pair[0]));
144
+ row.appendChild(el('span', null, pair[1]));
145
+ card.appendChild(row);
146
+ });
147
+ app.appendChild(card);
148
+ });
149
+
150
+ var agents = data.agents || [];
151
+ app.appendChild(el('h2', null, 'Agents (' + agents.length + ')'));
152
+ var strip = el('div', 'agents');
153
+ if (agents.length === 0) strip.appendChild(el('div', 'empty', 'none running'));
154
+ agents.forEach(function (a) {
155
+ var chip = el('div', 'agent');
156
+ chip.appendChild(el('div', 'name', a.agent + (a.role ? ' · ' + a.role : '')));
157
+ chip.appendChild(el('div', null, (a.init ? a.init + ' · ' : '') + (a.ticket || 'no ticket') + ' · ' + a.state));
158
+ if (a.detail) chip.appendChild(el('div', 'note', a.detail));
159
+ var ageMs = a.last_signal ? Date.now() - Date.parse(a.last_signal) : null;
160
+ var cls = ageMs === null ? 'age-cold' : ageMs < 600000 ? 'age-fresh' : ageMs < 1800000 ? 'age-warm' : 'age-cold';
161
+ var ageText = ageMs === null ? 'no signal' : Math.round(ageMs / 60000) + ' min since last signal';
162
+ chip.appendChild(el('div', cls, ageText));
163
+ strip.appendChild(chip);
164
+ });
165
+ app.appendChild(strip);
166
+
167
+ app.appendChild(el('h2', null, 'Lanes'));
168
+ var lanesWrap = el('div', 'lanes');
169
+ Object.keys(data.lanes || {}).forEach(function (lane) {
170
+ var cards = data.lanes[lane];
171
+ var box = el('div', 'lane ' + lane);
172
+ var h = el('h3');
173
+ h.appendChild(el('span', null, lane + ' '));
174
+ h.appendChild(el('span', 'count', '(' + cards.length + ')'));
175
+ box.appendChild(h);
176
+ if (cards.length === 0) box.appendChild(el('div', 'empty', '—'));
177
+ cards.forEach(function (c) {
178
+ var card = el('div', 'card');
179
+ card.appendChild(el('span', 'id', c.id));
180
+ if (c.title) card.appendChild(el('span', null, ' — ' + c.title));
181
+ if (c.init) card.appendChild(el('span', 'init', ' ' + c.init));
182
+ if (c.agents && c.agents.length) card.appendChild(el('span', 'note', 'agents: ' + c.agents.join(', ')));
183
+ if (c.annotation) card.appendChild(el('span', 'note', c.annotation));
184
+ box.appendChild(card);
185
+ });
186
+ lanesWrap.appendChild(box);
187
+ });
188
+ app.appendChild(lanesWrap);
189
+
190
+ // An initiative the board could not read is the one thing this page must
191
+ // never omit: a missing card is indistinguishable from an initiative with
192
+ // no work, which is the "all is well" reading the board exists to prevent.
193
+ var errors = data.errors || [];
194
+ if (errors.length > 0) {
195
+ app.appendChild(el('h2', null, 'Unreadable (' + errors.length + ')'));
196
+ errors.forEach(function (e) {
197
+ app.appendChild(el('div', 'paused', 'UNREADABLE — ' + e.name + ': ' + e.error));
198
+ });
199
+ }
200
+
201
+ var foot = el('footer');
202
+ foot.appendChild(el('div', null, 'GENERATED by tyran scripts/board.mjs — do not edit. Refreshes every 30 s; ages are computed in this browser.'));
203
+ app.appendChild(foot);
204
+ }
205
+ `;
206
+
207
+ /**
208
+ * The page, from an already-serialized cross-board JSON string (the exact
209
+ * bytes of board.json, so the two artefacts can never disagree). The extra
210
+ * `<` escape is the script-element breakout layer.
211
+ */
212
+ export function renderBoardHtml(payloadJsonText) {
213
+ const embedded = payloadJsonText.replace(/</g, '\\u003C');
214
+ return (
215
+ '<!doctype html>\n' +
216
+ '<!-- GENERATED by tyran scripts/board.mjs - DO NOT EDIT. Source of truth: the journals under .tyran/state/ -->\n' +
217
+ '<html lang="en"><head><meta charset="utf-8">\n' +
218
+ '<meta name="viewport" content="width=device-width, initial-scale=1">\n' +
219
+ '<meta http-equiv="refresh" content="30">\n' +
220
+ '<title>Tyran board</title>\n' +
221
+ `<style>${CSS}</style>\n` +
222
+ '</head><body><main id="app"></main>\n' +
223
+ `<script type="application/json" id="board-data">${embedded}</script>\n` +
224
+ `<script>${CLIENT_JS}</script>\n` +
225
+ '</body></html>\n'
226
+ );
227
+ }