@jjanczur/tyran 0.1.17 → 0.1.19
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +113 -0
- package/README.md +146 -420
- package/bin/tyran.mjs +4 -0
- package/package.json +1 -1
- package/scripts/board-html.mjs +439 -98
- package/scripts/board.mjs +31 -2
- package/scripts/cost.mjs +811 -0
- package/scripts/doctor.mjs +4 -0
- package/scripts/scan-repo.mjs +5 -0
- package/scripts/schema.mjs +89 -1
- package/templates/config.yaml +21 -0
package/bin/tyran.mjs
CHANGED
|
@@ -88,6 +88,10 @@ export const COMMANDS = {
|
|
|
88
88
|
'board.mjs',
|
|
89
89
|
'Render the cross-initiative kanban board — BOARD.md, board.json and the board.html dashboard — from the journals under .tyran/state/.',
|
|
90
90
|
],
|
|
91
|
+
cost: [
|
|
92
|
+
'cost.mjs',
|
|
93
|
+
'What the work cost, in tokens the platform reported — per model, per agent type and per ticket, priced by your own rate card.',
|
|
94
|
+
],
|
|
91
95
|
answer: [
|
|
92
96
|
'answer.mjs',
|
|
93
97
|
'Write the sheet of questions waiting on you, then fold your answers back into the journal.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jjanczur/tyran",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
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": {
|
package/scripts/board-html.mjs
CHANGED
|
@@ -9,16 +9,22 @@ import { FORBIDDEN } from './invisible.mjs';
|
|
|
9
9
|
* is blocked over file:// in Chromium, so meta-refresh is the one reliable
|
|
10
10
|
* primitive; under `board.mjs --serve` the same refresh hits the server.
|
|
11
11
|
*
|
|
12
|
-
* ##
|
|
12
|
+
* ## Four tabs, because the page answers four questions
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
14
|
+
* Overview (what is the state), Board (where is every ticket), Waiting on you
|
|
15
|
+
* (what is blocked on a decision, and how to answer it), Spend (what it
|
|
16
|
+
* cost). They were competing for one scroll. The queue keeps its count in the
|
|
17
|
+
* tab label, so "something is waiting on me" survives being on another tab.
|
|
18
|
+
*
|
|
19
|
+
* ## Style: the landing page's system, muted
|
|
20
|
+
*
|
|
21
|
+
* Roles are the landing page's — one warm accent for the operator's call to
|
|
22
|
+
* action, a cool one for the agent strip, red for refusal, green for the
|
|
23
|
+
* ledger's `+`. The TONES are deliberately pulled back from the first
|
|
24
|
+
* version (operator-decided 2026-08-14: "a bit too flashy"), which filled
|
|
25
|
+
* whole bars and whole cards at full saturation. Saturation is now spent on
|
|
26
|
+
* text, edges and 3px rails; every large fill is a muted tone of the same
|
|
27
|
+
* hue. System font stacks, no web fonts, dark only.
|
|
22
28
|
*
|
|
23
29
|
* ## Safety
|
|
24
30
|
*
|
|
@@ -36,48 +42,120 @@ import { FORBIDDEN } from './invisible.mjs';
|
|
|
36
42
|
|
|
37
43
|
const CSS = `
|
|
38
44
|
:root{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
--
|
|
45
|
+
/* Warm near-black ground, unchanged in role. The accents below are the
|
|
46
|
+
change: the first version filled whole bars and whole cards at full
|
|
47
|
+
saturation, which reads as an alarm rather than as information. Colour is
|
|
48
|
+
now spent on small things — text, edges, a 3px rail — and every large
|
|
49
|
+
fill drops to a muted tone of the same hue. */
|
|
50
|
+
--bg:#141210;--bg-raised:#1c1a16;--bg-sunken:#100e0c;
|
|
51
|
+
--text:#cec7ba;--heading:#ece5d7;--muted:#8f8779;
|
|
52
|
+
--hairline:#332e27;--hairline-soft:#26221d;
|
|
53
|
+
--brass:#a8863c;--brass-bright:#cfae63;--brass-low:#221c11;--brass-edge:#5d4c22;
|
|
54
|
+
--steel:#7d9ea9;--steel-bright:#9dbcc6;--steel-low:#17242a;--steel-edge:#3a545d;
|
|
55
|
+
--clay:#c07a70;--clay-low:#2a1a18;--sage:#88a06a;
|
|
45
56
|
--display:ui-serif,'Iowan Old Style','Palatino Linotype',Palatino,'Book Antiqua',Georgia,'Times New Roman',serif;
|
|
46
57
|
--font:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;
|
|
47
58
|
--mono:ui-monospace,SFMono-Regular,'SF Mono',Menlo,Consolas,'Liberation Mono',monospace;
|
|
48
|
-
--radius:0.
|
|
59
|
+
--radius:0.6rem;color-scheme:dark;
|
|
49
60
|
}
|
|
50
61
|
*{box-sizing:border-box}
|
|
51
62
|
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:
|
|
53
|
-
h1{font-family:var(--display);color:var(--heading);font-size:1.
|
|
54
|
-
h2{font-family:var(--display);color:var(--heading);font-size:1.
|
|
55
|
-
|
|
56
|
-
.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.
|
|
60
|
-
.
|
|
61
|
-
.
|
|
62
|
-
.
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
.
|
|
66
|
-
.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.
|
|
73
|
-
.
|
|
74
|
-
.
|
|
75
|
-
.
|
|
63
|
+
main{max-width:70rem;margin:0 auto}
|
|
64
|
+
h1{font-family:var(--display);color:var(--heading);font-size:1.5rem;margin:0 0 .2rem;font-weight:600}
|
|
65
|
+
h2{font-family:var(--display);color:var(--heading);font-size:1.02rem;margin:1.4rem 0 .5rem;border-bottom:1px solid var(--hairline-soft);padding-bottom:.3rem;font-weight:600}
|
|
66
|
+
h3{font-family:var(--font);color:var(--heading);font-size:.85rem;margin:1.1rem 0 .2rem;font-weight:650}
|
|
67
|
+
.meta{color:var(--muted);font-family:var(--mono);font-size:.78rem}
|
|
68
|
+
|
|
69
|
+
/* ---- tabs ---- */
|
|
70
|
+
.tabs{display:flex;flex-wrap:wrap;gap:.3rem;margin:.9rem 0 1.1rem;border-bottom:1px solid var(--hairline);padding-bottom:.5rem;position:sticky;top:0;background:var(--bg);z-index:5}
|
|
71
|
+
.tabs button{font-family:var(--font);font-size:.82rem;font-weight:600;letter-spacing:.01em;background:transparent;color:var(--muted);border:1px solid transparent;border-radius:.4rem;padding:.34rem .8rem;cursor:pointer}
|
|
72
|
+
.tabs button:hover{color:var(--text);background:var(--bg-raised)}
|
|
73
|
+
.tabs button[aria-selected="true"]{color:var(--brass-bright);background:var(--brass-low);border-color:var(--brass-edge)}
|
|
74
|
+
.tabs button:focus-visible{outline:2px solid var(--steel);outline-offset:2px}
|
|
75
|
+
.tabs .count{font-family:var(--mono);font-size:.72rem;opacity:.85;margin-left:.3rem}
|
|
76
|
+
.panel[hidden]{display:none}
|
|
77
|
+
.hint{color:var(--muted);font-size:.82rem;margin:.2rem 0 .9rem;max-width:52rem}
|
|
78
|
+
|
|
79
|
+
/* ---- banners ---- */
|
|
80
|
+
.paused{background:var(--clay-low);border:1px solid var(--clay);border-left:3px solid var(--clay);color:var(--clay);border-radius:var(--radius);padding:.55rem .85rem;margin:.7rem 0;font-weight:600;font-size:.9rem}
|
|
81
|
+
|
|
82
|
+
/* ---- tiles ---- */
|
|
83
|
+
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(10.5rem,1fr));gap:.55rem;margin:.5rem 0 .2rem}
|
|
84
|
+
.stile{background:var(--bg-raised);border:1px solid var(--hairline);border-radius:.5rem;padding:.6rem .8rem}
|
|
85
|
+
.stile .lbl{display:block;font-family:var(--mono);font-size:.63rem;text-transform:uppercase;letter-spacing:.09em;color:var(--muted)}
|
|
86
|
+
.stile .big{display:block;font-family:var(--mono);font-size:1.3rem;color:var(--heading);font-variant-numeric:tabular-nums;line-height:1.3}
|
|
87
|
+
.stile .sub{display:block;font-family:var(--mono);font-size:.68rem;color:var(--muted)}
|
|
88
|
+
.stile.lead{border-color:var(--brass-edge)}
|
|
89
|
+
.stile.lead .big{color:var(--brass-bright)}
|
|
90
|
+
.stile.warn{border-color:var(--clay)}
|
|
91
|
+
.stile.warn .big{color:var(--clay)}
|
|
92
|
+
|
|
93
|
+
/* ---- agents ---- */
|
|
94
|
+
.agents{display:flex;flex-wrap:wrap;gap:.45rem}
|
|
95
|
+
.agent{background:var(--bg-raised);border:1px solid var(--hairline);border-left:3px solid var(--steel-edge);border-radius:.45rem;padding:.42rem .65rem;font-family:var(--mono);font-size:.76rem;min-width:15rem}
|
|
96
|
+
.agent .name{color:var(--steel-bright);font-weight:600}
|
|
97
|
+
.agent .age-fresh{color:var(--sage)}
|
|
98
|
+
.agent .age-warm{color:var(--brass-bright)}
|
|
99
|
+
.agent .age-cold{color:var(--clay)}
|
|
100
|
+
|
|
101
|
+
/* ---- lanes ---- */
|
|
102
|
+
.lanes{display:grid;grid-template-columns:repeat(auto-fill,minmax(15rem,1fr));gap:.6rem;align-items:start}
|
|
103
|
+
.lane{background:var(--bg-sunken);border:1px solid var(--hairline-soft);border-radius:var(--radius);padding:.55rem}
|
|
104
|
+
.lane h4{margin:0 0 .35rem;font-size:.7rem;color:var(--muted);text-transform:uppercase;letter-spacing:.08em;font-family:var(--font);font-weight:650}
|
|
105
|
+
.lane h4 .count{color:var(--text);font-family:var(--mono)}
|
|
106
|
+
.lane.blocked{border-color:var(--clay)}
|
|
107
|
+
.lane.blocked h4 .count{color:var(--clay)}
|
|
108
|
+
.lane.done h4 .count{color:var(--sage)}
|
|
109
|
+
.lane.waiting-operator{border-color:var(--brass-edge)}
|
|
110
|
+
.lane.waiting-operator h4 .count{color:var(--brass-bright)}
|
|
111
|
+
.card{background:var(--bg-raised);border:1px solid var(--hairline);border-radius:.4rem;padding:.38rem .5rem;margin:.28rem 0;font-size:.82rem;cursor:pointer;text-align:left;width:100%;font-family:var(--font);color:var(--text);display:block}
|
|
112
|
+
.card:hover{border-color:var(--steel-edge)}
|
|
113
|
+
.card[aria-pressed="true"]{border-color:var(--brass);background:var(--brass-low)}
|
|
114
|
+
.card:focus-visible{outline:2px solid var(--steel);outline-offset:1px}
|
|
76
115
|
.card .id{font-family:var(--mono);color:var(--heading)}
|
|
77
|
-
.card .init{font-family:var(--mono);color:var(--muted);font-size:.
|
|
78
|
-
.card .note{color:var(--muted);font-size:.
|
|
79
|
-
.empty{color:var(--hairline);font-size:.
|
|
80
|
-
|
|
116
|
+
.card .init{font-family:var(--mono);color:var(--muted);font-size:.68rem}
|
|
117
|
+
.card .note{color:var(--muted);font-size:.74rem;display:block}
|
|
118
|
+
.empty{color:var(--hairline);font-size:.78rem}
|
|
119
|
+
|
|
120
|
+
/* ---- detail ---- */
|
|
121
|
+
.detail{background:var(--bg-raised);border:1px solid var(--hairline);border-left:3px solid var(--brass-edge);border-radius:var(--radius);padding:.8rem 1rem;margin:.9rem 0 0}
|
|
122
|
+
.detail .dt{font-family:var(--mono);color:var(--heading);font-size:.95rem}
|
|
123
|
+
.detail dl{display:grid;grid-template-columns:auto 1fr;gap:.2rem .8rem;margin:.5rem 0 0;font-size:.84rem}
|
|
124
|
+
.detail dt{font-family:var(--mono);font-size:.68rem;text-transform:uppercase;letter-spacing:.07em;color:var(--muted);padding-top:.16rem}
|
|
125
|
+
.detail dd{margin:0;color:var(--text)}
|
|
126
|
+
|
|
127
|
+
/* ---- questions ---- */
|
|
128
|
+
.ask{background:var(--brass-low);border:1px solid var(--brass-edge);border-left:3px solid var(--brass);border-radius:var(--radius);padding:.7rem .9rem;margin:.5rem 0}
|
|
129
|
+
.ask .q{color:var(--brass-bright);font-size:1rem;font-weight:600}
|
|
130
|
+
.ask .row{margin-top:.22rem;font-size:.86rem}
|
|
131
|
+
.ask .label{color:var(--muted);text-transform:uppercase;font-size:.66rem;letter-spacing:.07em;margin-right:.4rem;font-family:var(--mono)}
|
|
132
|
+
pre.how{background:var(--bg-sunken);border:1px solid var(--hairline);border-radius:.45rem;padding:.7rem .85rem;font-family:var(--mono);font-size:.76rem;color:var(--text);overflow-x:auto;margin:.4rem 0 .7rem}
|
|
133
|
+
pre.how .c{color:var(--muted)}
|
|
134
|
+
|
|
135
|
+
/* ---- spend ---- */
|
|
136
|
+
.spend-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:.7rem}
|
|
137
|
+
.toggle{display:flex;gap:.25rem;margin-left:auto}
|
|
138
|
+
.toggle button{font-family:var(--mono);font-size:.68rem;letter-spacing:.06em;text-transform:uppercase;background:var(--bg-raised);color:var(--muted);border:1px solid var(--hairline);border-radius:.3rem;padding:.18rem .55rem;cursor:pointer}
|
|
139
|
+
.toggle button[aria-pressed="true"]{background:var(--brass-low);border-color:var(--brass-edge);color:var(--brass-bright)}
|
|
140
|
+
.toggle button:focus-visible{outline:2px solid var(--steel);outline-offset:2px}
|
|
141
|
+
.comp{display:flex;height:1.35rem;border:1px solid var(--hairline);border-radius:.3rem;overflow:hidden;margin-top:.5rem}
|
|
142
|
+
.comp span{display:flex;align-items:center;justify-content:center;font-family:var(--mono);font-size:.63rem;color:var(--bg);font-weight:700;white-space:nowrap;overflow:hidden}
|
|
143
|
+
.comp .s-cache_read{background:var(--brass)}
|
|
144
|
+
.comp .s-cache_write{background:var(--steel)}
|
|
145
|
+
.comp .s-output{background:var(--sage)}
|
|
146
|
+
.comp .s-input{background:var(--muted)}
|
|
147
|
+
.compkey{display:flex;flex-wrap:wrap;gap:.85rem;font-family:var(--mono);font-size:.66rem;color:var(--muted);margin-top:.3rem}
|
|
148
|
+
.compkey i{display:inline-block;width:.55rem;height:.55rem;border-radius:.12rem;margin-right:.3rem}
|
|
149
|
+
.chart{display:flex;flex-direction:column;gap:.24rem;margin-top:.35rem}
|
|
150
|
+
.chartrow{display:grid;grid-template-columns:minmax(7rem,13rem) 1fr auto;gap:.55rem;align-items:center;font-size:.78rem}
|
|
151
|
+
.chartrow .rl{font-family:var(--mono);color:var(--heading);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
152
|
+
.chartrow .rb{background:var(--bg-sunken);border-radius:.2rem;height:.75rem;overflow:hidden}
|
|
153
|
+
.chartrow .rb i{display:block;height:100%;background:var(--brass);border-radius:.2rem;opacity:.85}
|
|
154
|
+
.chartrow.dim .rl{color:var(--muted);font-style:italic}
|
|
155
|
+
.chartrow.dim .rb i{background:var(--hairline)}
|
|
156
|
+
.chartrow .rv{font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--text);min-width:5.5rem;text-align:right}
|
|
157
|
+
.caveat{color:var(--muted);font-size:.76rem;margin-top:.5rem;max-width:52rem}
|
|
158
|
+
footer{margin-top:2rem;color:var(--muted);font-size:.72rem;border-top:1px solid var(--hairline-soft);padding-top:.6rem}
|
|
81
159
|
`;
|
|
82
160
|
|
|
83
161
|
/**
|
|
@@ -117,26 +195,201 @@ if (data.schema !== 1) {
|
|
|
117
195
|
if (text !== undefined && text !== null) node.textContent = show(text);
|
|
118
196
|
return node;
|
|
119
197
|
};
|
|
198
|
+
var clear = function (node) {
|
|
199
|
+
while (node.firstChild) node.removeChild(node.firstChild);
|
|
200
|
+
return node;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
var totals = data.totals || {};
|
|
204
|
+
var asks = data.asks || [];
|
|
205
|
+
var agents = data.agents || [];
|
|
206
|
+
var lanes = data.lanes || {};
|
|
207
|
+
var errors = data.errors || [];
|
|
208
|
+
var cost = null;
|
|
209
|
+
|
|
120
210
|
var app = document.getElementById('app');
|
|
121
211
|
var head = el('div');
|
|
122
212
|
head.appendChild(el('h1', null, 'Tyran board'));
|
|
123
|
-
var totals = data.totals || {};
|
|
124
213
|
head.appendChild(el('div', 'meta',
|
|
125
|
-
(totals.
|
|
126
|
-
|
|
214
|
+
(totals.initiatives || 0) + ' initiative(s) · ' + (totals.merged || 0) + '/' + (totals.tickets || 0) +
|
|
215
|
+
' tickets merged (' + (totals.percent || 0) + '%) · as of ' + (data.as_of || 'unknown')));
|
|
127
216
|
app.appendChild(head);
|
|
128
217
|
|
|
218
|
+
// ---- tabs -------------------------------------------------------------
|
|
219
|
+
// The board answers four different questions and they were competing for
|
|
220
|
+
// one scroll. Each gets a panel; the queue keeps its count in the tab, so
|
|
221
|
+
// "something is waiting on me" survives being on another tab.
|
|
222
|
+
var tabbar = el('div', 'tabs');
|
|
223
|
+
tabbar.setAttribute('role', 'tablist');
|
|
224
|
+
var panels = {};
|
|
225
|
+
var buttons = {};
|
|
226
|
+
var TABS = [
|
|
227
|
+
['overview', 'Overview', null],
|
|
228
|
+
['board', 'Board', null],
|
|
229
|
+
['questions', 'Waiting on you', asks.length],
|
|
230
|
+
['spend', 'Spend', null],
|
|
231
|
+
];
|
|
232
|
+
var select = function (key) {
|
|
233
|
+
for (var i = 0; i < TABS.length; i += 1) {
|
|
234
|
+
var k = TABS[i][0];
|
|
235
|
+
var on = k === key;
|
|
236
|
+
buttons[k].setAttribute('aria-selected', on ? 'true' : 'false');
|
|
237
|
+
panels[k].hidden = !on;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
TABS.forEach(function (spec) {
|
|
241
|
+
var b = el('button', null, spec[1]);
|
|
242
|
+
b.setAttribute('type', 'button');
|
|
243
|
+
b.setAttribute('role', 'tab');
|
|
244
|
+
if (spec[2] !== null && spec[2] !== undefined) b.appendChild(el('span', 'count', '(' + spec[2] + ')'));
|
|
245
|
+
b.addEventListener('click', function () { select(spec[0]); });
|
|
246
|
+
buttons[spec[0]] = b;
|
|
247
|
+
tabbar.appendChild(b);
|
|
248
|
+
var p = el('div', 'panel');
|
|
249
|
+
p.setAttribute('role', 'tabpanel');
|
|
250
|
+
panels[spec[0]] = p;
|
|
251
|
+
});
|
|
252
|
+
app.appendChild(tabbar);
|
|
253
|
+
TABS.forEach(function (spec) { app.appendChild(panels[spec[0]]); });
|
|
254
|
+
|
|
255
|
+
var tile = function (label, big, sub, cls) {
|
|
256
|
+
var box = el('div', cls ? 'stile ' + cls : 'stile');
|
|
257
|
+
box.appendChild(el('span', 'lbl', label));
|
|
258
|
+
box.appendChild(el('span', 'big', big));
|
|
259
|
+
box.appendChild(el('span', 'sub', sub));
|
|
260
|
+
return box;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
var fmtTokens = function (n) {
|
|
264
|
+
if (n >= 1e9) return (n / 1e9).toFixed(2) + ' B';
|
|
265
|
+
if (n >= 1e6) return (n / 1e6).toFixed(1) + ' M';
|
|
266
|
+
if (n >= 1e3) return (n / 1e3).toFixed(1) + ' k';
|
|
267
|
+
return String(n);
|
|
268
|
+
};
|
|
269
|
+
// An amount that rounds to nothing still cost something; printing $0.00
|
|
270
|
+
// there reads as free.
|
|
271
|
+
var fmtUsd = function (v) {
|
|
272
|
+
if (v === null || v === undefined) return '—';
|
|
273
|
+
if (v > 0 && v < 0.01) return '<$0.01';
|
|
274
|
+
return '$' + v.toFixed(2);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
var agentStrip = function () {
|
|
278
|
+
var strip = el('div', 'agents');
|
|
279
|
+
if (agents.length === 0) strip.appendChild(el('div', 'empty', 'none running'));
|
|
280
|
+
agents.forEach(function (a) {
|
|
281
|
+
var chip = el('div', 'agent');
|
|
282
|
+
chip.appendChild(el('div', 'name', a.agent + (a.role ? ' · ' + a.role : '')));
|
|
283
|
+
chip.appendChild(el('div', null, (a.init ? a.init + ' · ' : '') + (a.ticket || 'no ticket') + ' · ' + a.state));
|
|
284
|
+
if (a.detail) chip.appendChild(el('div', 'note', a.detail));
|
|
285
|
+
var ageMs = a.last_signal ? Date.now() - Date.parse(a.last_signal) : null;
|
|
286
|
+
var cls = ageMs === null ? 'age-cold' : ageMs < 600000 ? 'age-fresh' : ageMs < 1800000 ? 'age-warm' : 'age-cold';
|
|
287
|
+
var ageText = ageMs === null ? 'no signal' : Math.round(ageMs / 60000) + ' min since last signal';
|
|
288
|
+
chip.appendChild(el('div', cls, ageText));
|
|
289
|
+
strip.appendChild(chip);
|
|
290
|
+
});
|
|
291
|
+
return strip;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
// ---- overview ---------------------------------------------------------
|
|
295
|
+
var ov = panels.overview;
|
|
129
296
|
(data.paused || []).forEach(function (p) {
|
|
130
|
-
|
|
297
|
+
ov.appendChild(el('div', 'paused', 'PAUSED — ' + p.init + ': gate ' + p.kind + ' (' + p.result + ') since ' + p.since));
|
|
131
298
|
});
|
|
299
|
+
var laneCount = function (name) { return (lanes[name] || []).length; };
|
|
300
|
+
var ovTiles = el('div', 'tiles');
|
|
301
|
+
ovTiles.appendChild(tile('waiting on you', String(asks.length),
|
|
302
|
+
asks.length === 0 ? 'nothing blocked on a decision' : 'answer them on the next tab', asks.length > 0 ? 'lead' : null));
|
|
303
|
+
ovTiles.appendChild(tile('agents running', String(agents.length), 'across ' + (totals.initiatives || 0) + ' initiative(s)'));
|
|
304
|
+
ovTiles.appendChild(tile('progress', (totals.percent || 0) + '%', (totals.merged || 0) + ' of ' + (totals.tickets || 0) + ' merged'));
|
|
305
|
+
var stuck = laneCount('blocked') + laneCount('changes-requested');
|
|
306
|
+
ovTiles.appendChild(tile('needs a human', String(stuck),
|
|
307
|
+
laneCount('blocked') + ' blocked · ' + laneCount('changes-requested') + ' changes requested', stuck > 0 ? 'warn' : null));
|
|
308
|
+
ov.appendChild(ovTiles);
|
|
309
|
+
ov.appendChild(el('h2', null, 'Agents'));
|
|
310
|
+
ov.appendChild(agentStrip());
|
|
311
|
+
var ovSpend = el('div');
|
|
312
|
+
ov.appendChild(ovSpend);
|
|
132
313
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
314
|
+
// An initiative the board could not read is the one thing this page must
|
|
315
|
+
// never omit: a missing card is indistinguishable from an initiative with
|
|
316
|
+
// no work, which is the "all is well" reading the board exists to prevent.
|
|
317
|
+
if (errors.length > 0) {
|
|
318
|
+
ov.appendChild(el('h2', null, 'Unreadable (' + errors.length + ')'));
|
|
319
|
+
errors.forEach(function (e) {
|
|
320
|
+
ov.appendChild(el('div', 'paused', 'UNREADABLE — ' + e.name + ': ' + e.error));
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// ---- board ------------------------------------------------------------
|
|
325
|
+
var bd = panels.board;
|
|
326
|
+
bd.appendChild(el('div', 'hint', 'Every lane is derived from the journal — moving a ticket means appending an event, never editing this page. Select a card to see what the board knows about it.'));
|
|
327
|
+
var detail = el('div');
|
|
328
|
+
var selected = null;
|
|
329
|
+
var lanesWrap = el('div', 'lanes');
|
|
330
|
+
var showDetail = function (card, lane, button) {
|
|
331
|
+
if (selected) selected.setAttribute('aria-pressed', 'false');
|
|
332
|
+
selected = button;
|
|
333
|
+
button.setAttribute('aria-pressed', 'true');
|
|
334
|
+
clear(detail);
|
|
335
|
+
var box = el('div', 'detail');
|
|
336
|
+
box.appendChild(el('div', 'dt', card.id + (card.title ? ' — ' + card.title : '')));
|
|
337
|
+
var dl = el('dl');
|
|
338
|
+
var row = function (k, v) {
|
|
339
|
+
if (v === null || v === undefined || v === '') return;
|
|
340
|
+
dl.appendChild(el('dt', null, k));
|
|
341
|
+
dl.appendChild(el('dd', null, v));
|
|
342
|
+
};
|
|
343
|
+
row('lane', lane);
|
|
344
|
+
row('initiative', card.init);
|
|
345
|
+
row('agents', card.agents && card.agents.length ? card.agents.join(', ') : null);
|
|
346
|
+
row('note', card.annotation);
|
|
347
|
+
if (cost) {
|
|
348
|
+
var hit = (cost.by_ticket || []).filter(function (r) { return r.ticket === card.id; })[0];
|
|
349
|
+
if (hit) row('spend', fmtTokens(hit.tokens) + ' tokens · ' + fmtUsd(hit.usd));
|
|
350
|
+
}
|
|
351
|
+
box.appendChild(dl);
|
|
352
|
+
detail.appendChild(box);
|
|
353
|
+
};
|
|
354
|
+
Object.keys(lanes).forEach(function (lane) {
|
|
355
|
+
var cards = lanes[lane];
|
|
356
|
+
var box = el('div', 'lane ' + lane);
|
|
357
|
+
var h = el('h4');
|
|
358
|
+
h.appendChild(el('span', null, lane));
|
|
359
|
+
h.appendChild(el('span', 'count', ' (' + cards.length + ')'));
|
|
360
|
+
box.appendChild(h);
|
|
361
|
+
if (cards.length === 0) box.appendChild(el('div', 'empty', '—'));
|
|
362
|
+
cards.forEach(function (c) {
|
|
363
|
+
var button = el('button', 'card');
|
|
364
|
+
button.setAttribute('type', 'button');
|
|
365
|
+
button.setAttribute('aria-pressed', 'false');
|
|
366
|
+
button.appendChild(el('span', 'id', c.id));
|
|
367
|
+
if (c.title) button.appendChild(el('span', null, ' — ' + c.title));
|
|
368
|
+
if (c.init) button.appendChild(el('span', 'init', ' ' + c.init));
|
|
369
|
+
if (c.agents && c.agents.length) button.appendChild(el('span', 'note', 'agents: ' + c.agents.join(', ')));
|
|
370
|
+
if (c.annotation) button.appendChild(el('span', 'note', c.annotation));
|
|
371
|
+
button.addEventListener('click', function () { showDetail(c, lane, button); });
|
|
372
|
+
box.appendChild(button);
|
|
373
|
+
});
|
|
374
|
+
lanesWrap.appendChild(box);
|
|
375
|
+
});
|
|
376
|
+
bd.appendChild(lanesWrap);
|
|
377
|
+
bd.appendChild(detail);
|
|
378
|
+
|
|
379
|
+
// ---- questions --------------------------------------------------------
|
|
380
|
+
var qs = panels.questions;
|
|
381
|
+
qs.appendChild(el('div', 'hint', 'Every question here is a gate in the journal, and it stays open until you close it. Blank takes the recorded default and is still written down as your decision; a single dash leaves it for next time.'));
|
|
382
|
+
var how = el('pre', 'how');
|
|
383
|
+
how.textContent =
|
|
384
|
+
'npx @jjanczur/tyran answer render --dir .tyran # writes .tyran/state/ANSWERS.md\\n' +
|
|
385
|
+
'$EDITOR .tyran/state/ANSWERS.md # fill the answer: lines\\n' +
|
|
386
|
+
'npx @jjanczur/tyran answer apply --dir .tyran # closes what you answered';
|
|
387
|
+
qs.appendChild(how);
|
|
388
|
+
if (asks.length === 0) qs.appendChild(el('div', 'empty', 'nothing — the agents have what they need'));
|
|
136
389
|
asks.forEach(function (a) {
|
|
137
390
|
var card = el('div', 'ask');
|
|
138
391
|
card.appendChild(el('div', 'q', a.question || '(no question recorded — gate ' + a.kind + ')'));
|
|
139
|
-
[['recommendation', a.recommendation], ['default', a.default],
|
|
392
|
+
[['answer with', a.kind], ['recommendation', a.recommendation], ['default', a.default],
|
|
140
393
|
['ticket', a.ticket], ['initiative', a.init], ['since', a.since]].forEach(function (pair) {
|
|
141
394
|
if (pair[1] === null || pair[1] === undefined) return;
|
|
142
395
|
var row = el('div', 'row');
|
|
@@ -144,60 +397,148 @@ if (data.schema !== 1) {
|
|
|
144
397
|
row.appendChild(el('span', null, pair[1]));
|
|
145
398
|
card.appendChild(row);
|
|
146
399
|
});
|
|
147
|
-
|
|
400
|
+
qs.appendChild(card);
|
|
148
401
|
});
|
|
149
402
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
|
|
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);
|
|
403
|
+
// ---- spend ------------------------------------------------------------
|
|
404
|
+
var sp = panels.spend;
|
|
405
|
+
var spBody = el('div');
|
|
406
|
+
sp.appendChild(spBody);
|
|
407
|
+
spBody.appendChild(el('div', 'hint', 'Spend is read from the transcripts Claude Code already writes, and it is served rather than embedded — open this board with "board.mjs --serve" to see it. Over file:// there is no server, so this tab stays empty.'));
|
|
166
408
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
var
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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);
|
|
409
|
+
var chart = function (allRows, key, metric, dimKeys) {
|
|
410
|
+
var box = el('div', 'chart');
|
|
411
|
+
// Ranked by the metric on screen, not by the one the server sorted by:
|
|
412
|
+
// in cost view a cheap-and-chatty row above an expensive-and-terse one
|
|
413
|
+
// is the exact inversion of the signal this view exists to give.
|
|
414
|
+
var valueOf = function (r) { return metric === 'usd' ? r.usd : r.tokens; };
|
|
415
|
+
var rows = allRows.slice().sort(function (a, b) {
|
|
416
|
+
var av = valueOf(a);
|
|
417
|
+
var bv = valueOf(b);
|
|
418
|
+
if (typeof av !== 'number' && typeof bv !== 'number') return 0;
|
|
419
|
+
if (typeof av !== 'number') return 1;
|
|
420
|
+
if (typeof bv !== 'number') return -1;
|
|
421
|
+
return bv - av || String(a[key]).localeCompare(String(b[key]));
|
|
185
422
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
423
|
+
var values = rows.map(valueOf);
|
|
424
|
+
var max = 0;
|
|
425
|
+
values.forEach(function (v) { if (typeof v === 'number' && v > max) max = v; });
|
|
426
|
+
rows.forEach(function (r, i) {
|
|
427
|
+
var value = values[i];
|
|
428
|
+
var unpriced = metric === 'usd' && (value === null || value === undefined);
|
|
429
|
+
var dim = unpriced || dimKeys.indexOf(r[key]) !== -1;
|
|
430
|
+
var row = el('div', dim ? 'chartrow dim' : 'chartrow');
|
|
431
|
+
row.appendChild(el('div', 'rl', r[key]));
|
|
432
|
+
var track = el('div', 'rb');
|
|
433
|
+
var fill = el('i');
|
|
434
|
+
fill.style.width = (max > 0 && typeof value === 'number' ? (value / max) * 100 : 0) + '%';
|
|
435
|
+
track.appendChild(fill);
|
|
436
|
+
row.appendChild(track);
|
|
437
|
+
row.appendChild(el('div', 'rv', metric === 'usd' ? fmtUsd(value) : fmtTokens(value)));
|
|
438
|
+
box.appendChild(row);
|
|
439
|
+
});
|
|
440
|
+
return box;
|
|
441
|
+
};
|
|
189
442
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
443
|
+
var renderSpend = function (into, metric) {
|
|
444
|
+
clear(into);
|
|
445
|
+
var t = cost.totals || {};
|
|
446
|
+
var cov = cost.coverage || {};
|
|
447
|
+
var header = el('div', 'spend-head');
|
|
448
|
+
header.appendChild(el('h2', null, 'Spend'));
|
|
449
|
+
var toggle = el('div', 'toggle');
|
|
450
|
+
[['tokens', 'tokens'], ['usd', 'cost']].forEach(function (pair) {
|
|
451
|
+
var button = el('button', null, pair[1]);
|
|
452
|
+
button.setAttribute('type', 'button');
|
|
453
|
+
button.setAttribute('aria-pressed', metric === pair[0] ? 'true' : 'false');
|
|
454
|
+
button.addEventListener('click', function () { renderSpend(into, pair[0]); });
|
|
455
|
+
toggle.appendChild(button);
|
|
198
456
|
});
|
|
457
|
+
header.appendChild(toggle);
|
|
458
|
+
into.appendChild(header);
|
|
459
|
+
|
|
460
|
+
var tiles = el('div', 'tiles');
|
|
461
|
+
tiles.appendChild(tile('tokens', fmtTokens(t.tokens || 0), (t.requests || 0) + ' requests'));
|
|
462
|
+
tiles.appendChild(tile('cost through the API', fmtUsd(t.usd),
|
|
463
|
+
cost.rate_card ? 'rate card ' + cost.rate_card : 'no rate card set', 'lead'));
|
|
464
|
+
tiles.appendChild(tile('conductor overhead', (t.conductor_token_share || 0) + '%', 'of tokens, no ticket'));
|
|
465
|
+
tiles.appendChild(tile('attributed', (cov.attributed || 0) + ' / ' + (cov.agent_transcripts || 0),
|
|
466
|
+
(cov.unattributed || 0) + ' agent(s) without a ticket'));
|
|
467
|
+
into.appendChild(tiles);
|
|
468
|
+
|
|
469
|
+
// The composition is the point of the whole tab: cache reads dominate the
|
|
470
|
+
// bill, so the lever is context size and turn count, not model price.
|
|
471
|
+
var comp = (cost.composition || []).slice().sort(function (a, b) {
|
|
472
|
+
return metric === 'usd' ? (b.usd || 0) - (a.usd || 0) : b.tokens - a.tokens;
|
|
473
|
+
});
|
|
474
|
+
var compTotal = 0;
|
|
475
|
+
comp.forEach(function (c) { compTotal += metric === 'usd' ? (c.usd || 0) : c.tokens; });
|
|
476
|
+
if (compTotal > 0) {
|
|
477
|
+
var bar = el('div', 'comp');
|
|
478
|
+
var key = el('div', 'compkey');
|
|
479
|
+
comp.forEach(function (c) {
|
|
480
|
+
var value = metric === 'usd' ? (c.usd || 0) : c.tokens;
|
|
481
|
+
if (value <= 0) return;
|
|
482
|
+
var pct = Math.round((value / compTotal) * 100);
|
|
483
|
+
var seg = el('span', 's-' + c.kind, pct >= 8 ? pct + '%' : '');
|
|
484
|
+
// Normalised to a share: flex-grow below 1 does not fill its
|
|
485
|
+
// container, and dollar amounts are routinely fractions.
|
|
486
|
+
seg.style.flex = String((value / compTotal) * 100);
|
|
487
|
+
bar.appendChild(seg);
|
|
488
|
+
var legend = el('span', null);
|
|
489
|
+
legend.appendChild(el('i', 's-' + c.kind));
|
|
490
|
+
legend.appendChild(el('span', null,
|
|
491
|
+
c.kind.replace('_', ' ') + ' ' + (metric === 'usd' ? fmtUsd(c.usd) : fmtTokens(c.tokens))));
|
|
492
|
+
key.appendChild(legend);
|
|
493
|
+
});
|
|
494
|
+
into.appendChild(bar);
|
|
495
|
+
into.appendChild(key);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
[['By model', cost.by_model || [], 'model', []],
|
|
499
|
+
['By agent type', cost.by_agent_type || [], 'agent_type', ['conductor']],
|
|
500
|
+
['By ticket', cost.by_ticket || [], 'ticket', ['conductor', 'unattributed']]].forEach(function (spec) {
|
|
501
|
+
into.appendChild(el('h3', null, spec[0]));
|
|
502
|
+
into.appendChild(chart(spec[1], spec[2], metric, spec[3]));
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
var notes = ['Conductor context is not attributable to any ticket; it is its own row so the rows sum to the total.'];
|
|
506
|
+
if ((cov.unattributed || 0) > 0) {
|
|
507
|
+
notes.push(cov.unattributed + ' agent(s) carry no ticket id in their task description and are grouped as unattributed.');
|
|
508
|
+
}
|
|
509
|
+
if ((cost.unpriced || []).length > 0) {
|
|
510
|
+
notes.push('Counted in tokens but absent from every amount, having no rate: ' + cost.unpriced.join(', ') + '.');
|
|
511
|
+
}
|
|
512
|
+
if ((cov.malformed || 0) > 0 || (cov.skipped_lines || 0) > 0) {
|
|
513
|
+
notes.push((cov.malformed || 0) + ' unparseable and ' + (cov.skipped_lines || 0) +
|
|
514
|
+
' oversized record(s) were skipped; their tokens are missing from every figure here.');
|
|
515
|
+
}
|
|
516
|
+
into.appendChild(el('div', 'caveat', notes.join(' ')));
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// Spend is FETCHED, never embedded: it is derived from transcripts under
|
|
520
|
+
// the operator's home directory — machine-local, different in every clone —
|
|
521
|
+
// so writing it into board.json would break the byte-exact --check contract
|
|
522
|
+
// and make two people with one journal disagree.
|
|
523
|
+
if (typeof fetch === 'function') {
|
|
524
|
+
fetch('cost.json', { headers: { accept: 'application/json' } })
|
|
525
|
+
.then(function (r) { return r.ok ? r.json() : null; })
|
|
526
|
+
.then(function (payload) {
|
|
527
|
+
if (!payload || payload.schema !== 1 || !payload.transcripts_found) return;
|
|
528
|
+
cost = payload;
|
|
529
|
+
renderSpend(spBody, 'tokens');
|
|
530
|
+
var t = cost.totals || {};
|
|
531
|
+
var strip = el('div', 'tiles');
|
|
532
|
+
strip.appendChild(tile('spend so far', fmtUsd(t.usd),
|
|
533
|
+
fmtTokens(t.tokens || 0) + ' tokens · see the Spend tab'));
|
|
534
|
+
ovSpend.appendChild(el('h2', null, 'Spend'));
|
|
535
|
+
ovSpend.appendChild(strip);
|
|
536
|
+
})
|
|
537
|
+
.catch(function () { /* no server: the board is complete without it */ });
|
|
199
538
|
}
|
|
200
539
|
|
|
540
|
+
select('overview');
|
|
541
|
+
|
|
201
542
|
var foot = el('footer');
|
|
202
543
|
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
544
|
app.appendChild(foot);
|