@jjanczur/tyran 0.1.11 → 0.1.12
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 +24 -0
- package/README.md +5 -3
- package/bin/tyran.mjs +4 -0
- package/hooks/hooks.json +10 -0
- package/hooks/scripts/board-refresh.mjs +89 -0
- package/package.json +1 -1
- package/scripts/board-html.mjs +227 -0
- package/scripts/board.mjs +352 -0
- package/scripts/doctor.mjs +42 -0
- package/scripts/project.mjs +257 -4
- package/skills/run/SKILL.md +5 -2
- package/skills/status/SKILL.md +5 -1
|
@@ -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.
|
|
14
|
+
"version": "0.1.12",
|
|
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.
|
|
3
|
+
"version": "0.1.12",
|
|
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,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.12 — 2026-08-13
|
|
4
|
+
|
|
5
|
+
### The board: every ticket in a lane, every question in front of you
|
|
6
|
+
|
|
7
|
+
The read-only dashboard the roadmap promised, built the only way this state
|
|
8
|
+
layer allows: as a projection. `BOARD.md`/`board.json` render next to every
|
|
9
|
+
journal with the other projections; `scripts/board.mjs` folds every
|
|
10
|
+
initiative into one `.tyran/state/BOARD.md`, `board.json` (schema 1) and
|
|
11
|
+
`board.html` — a self-contained page in the landing page's own stone/gold/
|
|
12
|
+
glow palette that refreshes itself, puts the waiting-on-you queue first
|
|
13
|
+
(question, recommendation, default), lights the agent strip with each
|
|
14
|
+
agent's own last signal, and computes ages in the browser so the artefact
|
|
15
|
+
itself stays clock-free and byte-checkable. `--serve` adds a loopback-only
|
|
16
|
+
always-fresh viewer.
|
|
17
|
+
|
|
18
|
+
Lanes derive strongest-verdict-first from events that already exist —
|
|
19
|
+
`merge`, reviews, reports, running spawns, dep satisfaction (an unknown dep
|
|
20
|
+
refuses to schedule), blockages, `ticket.status` overrides, operator asks
|
|
21
|
+
(`WAITING_ON_OPERATOR` gates; `answered` joins the pass set), and the
|
|
22
|
+
overnight pause. A `SubagentStop` probe re-renders after every agent, with
|
|
23
|
+
the CLI's own damaged-journal refusal mirrored so an empty render never
|
|
24
|
+
clobbers good state; doctor gains `board-absent` (info) and drift coverage
|
|
25
|
+
for the new pair; an unreadable initiative is a visible UNREADABLE entry.
|
|
26
|
+
|
|
3
27
|
## 0.1.11 — 2026-08-13
|
|
4
28
|
|
|
5
29
|
### 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 (
|
|
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
|
-
- [
|
|
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
|
@@ -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.
|
|
3
|
+
"version": "0.1.12",
|
|
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
|
+
}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* board — the cross-initiative kanban view.
|
|
4
|
+
*
|
|
5
|
+
* `project.mjs` renders one initiative's BOARD.md/board.json next to its
|
|
6
|
+
* journal; this tool folds EVERY journal under `.tyran/state/` into one
|
|
7
|
+
* board — the answer to "what is going on" that previously required opening
|
|
8
|
+
* one file per initiative (measured install: 31). Three artefacts, all
|
|
9
|
+
* GENERATED, all under `state/` where the AUTO policy class already covers
|
|
10
|
+
* them:
|
|
11
|
+
*
|
|
12
|
+
* .tyran/state/BOARD.md the agent/git surface
|
|
13
|
+
* .tyran/state/board.json schema 1, for tooling
|
|
14
|
+
* .tyran/state/board.html the page an operator stares at (board-html.mjs)
|
|
15
|
+
*
|
|
16
|
+
* Determinism carries over from the projection layer: no clock (the page
|
|
17
|
+
* shows the newest event ts as "as of"), byte-identical reruns, invisibles
|
|
18
|
+
* escaped never removed, `--check` compares bytes. An unreadable journal is a
|
|
19
|
+
* visible error entry, never a crash — a board that omits a broken
|
|
20
|
+
* initiative reads as "all is well" exactly when it is not.
|
|
21
|
+
*
|
|
22
|
+
* CLI:
|
|
23
|
+
* node board.mjs [--dir <.tyran>] [--check] [--serve [--port <n>]]
|
|
24
|
+
* Exit: 0 ok · 1 drift (--check) · 2 usage/IO
|
|
25
|
+
*/
|
|
26
|
+
import { existsSync, readdirSync, statSync, readFileSync } from 'node:fs';
|
|
27
|
+
import { createServer } from 'node:http';
|
|
28
|
+
import { join, resolve } from 'node:path';
|
|
29
|
+
import { realpathSync } from 'node:fs';
|
|
30
|
+
import { fileURLToPath } from 'node:url';
|
|
31
|
+
import { readJournal } from './journal.mjs';
|
|
32
|
+
import {
|
|
33
|
+
BOARD_FILE,
|
|
34
|
+
BOARD_JSON_FILE,
|
|
35
|
+
LANES,
|
|
36
|
+
boardOf,
|
|
37
|
+
checkFile,
|
|
38
|
+
fold,
|
|
39
|
+
inline,
|
|
40
|
+
writeAllAtomic,
|
|
41
|
+
} from './project.mjs';
|
|
42
|
+
import { jsonEscapeInvisible } from './invisible.mjs';
|
|
43
|
+
import { renderBoardHtml } from './board-html.mjs';
|
|
44
|
+
|
|
45
|
+
export const BOARD_HTML_FILE = 'board.html';
|
|
46
|
+
|
|
47
|
+
/** Same ceiling as the evidence gate's journal locator — a deliberate
|
|
48
|
+
* duplicate: scripts must not import from hook files (direction is
|
|
49
|
+
* hooks -> scripts), and the constant is one number with one meaning. */
|
|
50
|
+
export const MAX_INITIATIVES = 64;
|
|
51
|
+
|
|
52
|
+
const GENERATED_MD_HEADER =
|
|
53
|
+
'<!-- GENERATED by tyran scripts/board.mjs - DO NOT EDIT. Source of truth: the journals under .tyran/state/ -->\n' +
|
|
54
|
+
'<!-- Regenerate: node scripts/board.mjs --dir <.tyran> -->\n';
|
|
55
|
+
|
|
56
|
+
class UsageError extends Error {}
|
|
57
|
+
|
|
58
|
+
/** Every initiative folded to its board; failures become visible entries. */
|
|
59
|
+
export function readInitiativeBoards(tyranDir) {
|
|
60
|
+
const stateDir = join(tyranDir, 'state');
|
|
61
|
+
let names;
|
|
62
|
+
try {
|
|
63
|
+
names = readdirSync(stateDir).sort();
|
|
64
|
+
} catch {
|
|
65
|
+
return { initiatives: [], errors: [] };
|
|
66
|
+
}
|
|
67
|
+
const dirs = names.filter((name) => {
|
|
68
|
+
try {
|
|
69
|
+
return statSync(join(stateDir, name)).isDirectory();
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (dirs.length > MAX_INITIATIVES) {
|
|
75
|
+
throw new UsageError(
|
|
76
|
+
`${dirs.length} initiative directories under ${stateDir} — the ceiling is ${MAX_INITIATIVES}. ` +
|
|
77
|
+
'Archive closed initiatives out of state/ before rendering a board over them.',
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
const initiatives = [];
|
|
81
|
+
const errors = [];
|
|
82
|
+
for (const name of dirs) {
|
|
83
|
+
const journal = join(stateDir, name, 'journal.jsonl');
|
|
84
|
+
if (!existsSync(journal)) continue;
|
|
85
|
+
try {
|
|
86
|
+
const state = fold(readJournal(journal));
|
|
87
|
+
// `readJournal` does NOT throw on unparseable content — it returns zero
|
|
88
|
+
// events and counts the damage — so the catch below never sees a corrupt
|
|
89
|
+
// journal. Without this guard a damaged file renders as an initiative
|
|
90
|
+
// with nothing wrong, which is the one output this board must never
|
|
91
|
+
// produce. Same condition the CLI and the refresh probe refuse on.
|
|
92
|
+
if (state.total === 0 && (state.corruptLines + state.malformed > 0 || state.truncatedTail)) {
|
|
93
|
+
const damage = [
|
|
94
|
+
state.corruptLines > 0 ? `${state.corruptLines} corrupt line(s)` : null,
|
|
95
|
+
state.malformed > 0 ? `${state.malformed} non-object line(s)` : null,
|
|
96
|
+
state.truncatedTail ? 'a truncated final line' : null,
|
|
97
|
+
].filter(Boolean).join(', ');
|
|
98
|
+
errors.push({ name, error: `0 readable events and ${damage} — the journal is damaged` });
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
initiatives.push({ name, state, board: boardOf(state) });
|
|
102
|
+
} catch (err) {
|
|
103
|
+
errors.push({ name, error: String(err?.message ?? err) });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return { initiatives, errors };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Pure merge of per-initiative boards into the one payload. */
|
|
110
|
+
export function crossBoard({ initiatives, errors }) {
|
|
111
|
+
const asks = [];
|
|
112
|
+
const agents = [];
|
|
113
|
+
const paused = [];
|
|
114
|
+
const lanes = Object.fromEntries(LANES.map((lane) => [lane, []]));
|
|
115
|
+
let merged = 0;
|
|
116
|
+
let tickets = 0;
|
|
117
|
+
let asOf = null;
|
|
118
|
+
|
|
119
|
+
for (const { name, state, board } of initiatives) {
|
|
120
|
+
merged += state.merged;
|
|
121
|
+
tickets += state.ticketList.length;
|
|
122
|
+
if (state.lastTs !== null && (asOf === null || state.lastTs > asOf)) asOf = state.lastTs;
|
|
123
|
+
for (const a of board.asks) asks.push({ ...a, init: name });
|
|
124
|
+
for (const a of board.agents) agents.push({ ...a, init: name });
|
|
125
|
+
if (board.paused !== null) paused.push({ ...board.paused, init: name });
|
|
126
|
+
for (const lane of LANES) {
|
|
127
|
+
for (const card of board.lanes.get(lane)) lanes[lane].push({ ...card, init: name });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
asks.sort((a, b) => String(a.since ?? '').localeCompare(String(b.since ?? '')));
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
schema: 1,
|
|
134
|
+
as_of: asOf,
|
|
135
|
+
totals: {
|
|
136
|
+
initiatives: initiatives.length,
|
|
137
|
+
agents: agents.length,
|
|
138
|
+
merged,
|
|
139
|
+
tickets,
|
|
140
|
+
percent: tickets === 0 ? 0 : Math.round((merged / tickets) * 100),
|
|
141
|
+
},
|
|
142
|
+
paused,
|
|
143
|
+
asks,
|
|
144
|
+
agents,
|
|
145
|
+
lanes,
|
|
146
|
+
errors,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function crossJson(payload) {
|
|
151
|
+
return jsonEscapeInvisible(JSON.stringify(payload, null, 2)) + '\n';
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function renderCrossMd(payload) {
|
|
155
|
+
const parts = [GENERATED_MD_HEADER, '# BOARD — all initiatives\n\n'];
|
|
156
|
+
const t = payload.totals;
|
|
157
|
+
parts.push(
|
|
158
|
+
`**${t.agents} agent(s) running across ${t.initiatives} initiative(s) · ` +
|
|
159
|
+
`${t.merged}/${t.tickets} tickets merged (${t.percent}%) · as of ${inline(payload.as_of)}**\n`,
|
|
160
|
+
);
|
|
161
|
+
for (const p of payload.paused) {
|
|
162
|
+
parts.push(`\n**PAUSED** — ${inline(p.init)}: gate ${inline(p.kind)} (${inline(p.result)}) since ${inline(p.since)}\n`);
|
|
163
|
+
}
|
|
164
|
+
for (const e of payload.errors) {
|
|
165
|
+
parts.push(`\n**UNREADABLE** — ${inline(e.name)}: ${inline(e.error)}\n`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
parts.push('\n## Waiting on you\n\n');
|
|
169
|
+
if (payload.asks.length === 0) parts.push('_none — the agents have what they need_\n');
|
|
170
|
+
for (const a of payload.asks) {
|
|
171
|
+
parts.push(`- **${inline(a.question ?? `(no question recorded — gate ${a.kind})`)}**\n`);
|
|
172
|
+
if (a.recommendation != null) parts.push(` - recommendation: ${inline(a.recommendation)}\n`);
|
|
173
|
+
if (a.default != null) parts.push(` - default: ${inline(a.default)}\n`);
|
|
174
|
+
parts.push(` - ${inline(a.init)}${a.ticket != null ? ` · \`${inline(a.ticket)}\`` : ''} · since ${inline(a.since)}\n`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
parts.push('\n## Agents\n\n');
|
|
178
|
+
if (payload.agents.length === 0) parts.push('_none running_\n');
|
|
179
|
+
for (const a of payload.agents) {
|
|
180
|
+
parts.push(
|
|
181
|
+
`- \`${inline(a.agent)}\` (${inline(a.role)}) — ${inline(a.init)}` +
|
|
182
|
+
`${a.ticket != null ? ` · \`${inline(a.ticket)}\`` : ''} · ${inline(a.state)}` +
|
|
183
|
+
`${a.detail != null ? ` — ${inline(a.detail)}` : ''} · last signal ${inline(a.last_signal)}\n`,
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
for (const lane of LANES) {
|
|
188
|
+
const cards = payload.lanes[lane];
|
|
189
|
+
parts.push(`\n## ${lane} (${cards.length})\n\n`);
|
|
190
|
+
if (cards.length === 0) {
|
|
191
|
+
parts.push('_none_\n');
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
for (const c of cards) {
|
|
195
|
+
parts.push(
|
|
196
|
+
`- \`${inline(c.id)}\`${c.title ? ` — ${inline(c.title)}` : ''} _(${inline(c.init)})_` +
|
|
197
|
+
`${c.agents.length > 0 ? ` — ${inline(c.agents)}` : ''}` +
|
|
198
|
+
`${c.annotation ? ` — ${inline(c.annotation)}` : ''}\n`,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return parts.join('');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function renderAll(tyranDir) {
|
|
206
|
+
const payload = crossBoard(readInitiativeBoards(tyranDir));
|
|
207
|
+
const json = crossJson(payload);
|
|
208
|
+
return {
|
|
209
|
+
payload,
|
|
210
|
+
files: {
|
|
211
|
+
[BOARD_FILE]: renderCrossMd(payload),
|
|
212
|
+
[BOARD_JSON_FILE]: json,
|
|
213
|
+
[BOARD_HTML_FILE]: renderBoardHtml(json.trimEnd()),
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ------------------------------------------------------------------- CLI
|
|
219
|
+
|
|
220
|
+
const BOOLEAN_FLAGS = ['check', 'serve'];
|
|
221
|
+
const VALUE_FLAGS = ['dir', 'port'];
|
|
222
|
+
|
|
223
|
+
function parseArgs(argv) {
|
|
224
|
+
const flags = { dir: '.tyran', port: 4173, check: false, serve: false };
|
|
225
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
226
|
+
const arg = argv[i];
|
|
227
|
+
if (!arg.startsWith('--')) throw new UsageError(`unexpected argument "${arg}"`);
|
|
228
|
+
const name = arg.slice(2);
|
|
229
|
+
if (BOOLEAN_FLAGS.includes(name)) flags[name] = true;
|
|
230
|
+
else if (VALUE_FLAGS.includes(name)) {
|
|
231
|
+
const value = argv[i + 1];
|
|
232
|
+
if (value === undefined) throw new UsageError(`flag --${name} needs a value`);
|
|
233
|
+
flags[name] = name === 'port' ? Number(value) : value;
|
|
234
|
+
i += 1;
|
|
235
|
+
} else throw new UsageError(`unknown flag --${name}`);
|
|
236
|
+
}
|
|
237
|
+
if (!Number.isInteger(flags.port) || flags.port <= 0 || flags.port > 65535) {
|
|
238
|
+
throw new UsageError('--port must be an integer in (0, 65535]');
|
|
239
|
+
}
|
|
240
|
+
return flags;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function main() {
|
|
244
|
+
let flags;
|
|
245
|
+
try {
|
|
246
|
+
flags = parseArgs(process.argv.slice(2));
|
|
247
|
+
} catch (err) {
|
|
248
|
+
if (!(err instanceof UsageError)) throw err;
|
|
249
|
+
console.error(`board: ${err.message}`);
|
|
250
|
+
console.error('usage: board.mjs [--dir <.tyran>] [--check] [--serve [--port <n>]]');
|
|
251
|
+
process.exit(2);
|
|
252
|
+
}
|
|
253
|
+
const dir = resolve(flags.dir);
|
|
254
|
+
if (!existsSync(dir)) {
|
|
255
|
+
console.error(`board: no such directory ${dir}`);
|
|
256
|
+
process.exit(2);
|
|
257
|
+
}
|
|
258
|
+
const outDir = join(dir, 'state');
|
|
259
|
+
|
|
260
|
+
if (flags.serve) {
|
|
261
|
+
// Read-only, loopback-only, re-rendered per request so it is always
|
|
262
|
+
// fresh. No filesystem path is ever derived from the URL.
|
|
263
|
+
const server = createServer((req, res) => {
|
|
264
|
+
try {
|
|
265
|
+
// Binding to loopback is not enough on its own: any web page the
|
|
266
|
+
// operator visits can resolve its own hostname to 127.0.0.1 and read
|
|
267
|
+
// this board — which carries journal content from foreign
|
|
268
|
+
// repositories — straight out of the browser (DNS rebinding). A
|
|
269
|
+
// browser cannot forge the Host header, so pinning it to the literal
|
|
270
|
+
// loopback names closes that path.
|
|
271
|
+
const host = String(req.headers.host ?? '').replace(/:\d+$/, '');
|
|
272
|
+
if (host !== '127.0.0.1' && host !== 'localhost' && host !== '[::1]') {
|
|
273
|
+
res.writeHead(403, { 'content-type': 'text/plain' });
|
|
274
|
+
res.end('forbidden: this board answers to 127.0.0.1 only\n');
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const { files } = renderAll(dir);
|
|
278
|
+
if (req.url === '/' || req.url === '/index.html') {
|
|
279
|
+
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
|
|
280
|
+
res.end(files[BOARD_HTML_FILE]);
|
|
281
|
+
} else if (req.url === '/board.json') {
|
|
282
|
+
res.writeHead(200, { 'content-type': 'application/json; charset=utf-8' });
|
|
283
|
+
res.end(files[BOARD_JSON_FILE]);
|
|
284
|
+
} else {
|
|
285
|
+
res.writeHead(404, { 'content-type': 'text/plain' });
|
|
286
|
+
res.end('not found\n');
|
|
287
|
+
}
|
|
288
|
+
} catch (err) {
|
|
289
|
+
res.writeHead(500, { 'content-type': 'text/plain' });
|
|
290
|
+
res.end(`board render failed: ${String(err?.message ?? err)}\n`);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
// A busy port is an ordinary operator mistake, not a crash worth a stack
|
|
294
|
+
// trace over.
|
|
295
|
+
server.on('error', (err) => {
|
|
296
|
+
console.error(
|
|
297
|
+
err?.code === 'EADDRINUSE'
|
|
298
|
+
? `board: port ${flags.port} is already in use — pass --port <n> for another`
|
|
299
|
+
: `board: could not serve: ${String(err?.message ?? err)}`,
|
|
300
|
+
);
|
|
301
|
+
process.exitCode = 2;
|
|
302
|
+
});
|
|
303
|
+
server.listen(flags.port, '127.0.0.1', () => {
|
|
304
|
+
console.log(`board: serving http://127.0.0.1:${flags.port}/ (read-only; Ctrl-C to stop)`);
|
|
305
|
+
});
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
let rendered;
|
|
310
|
+
try {
|
|
311
|
+
rendered = renderAll(dir);
|
|
312
|
+
} catch (err) {
|
|
313
|
+
console.error(`board: ${err.message}`);
|
|
314
|
+
process.exit(2);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (flags.check) {
|
|
318
|
+
let drift = 0;
|
|
319
|
+
for (const [name, content] of Object.entries(rendered.files)) {
|
|
320
|
+
const verdict = checkFile(join(outDir, name), content);
|
|
321
|
+
if (!verdict.ok) {
|
|
322
|
+
drift++;
|
|
323
|
+
console.error(`board: drift: ${join(outDir, name)} — ${verdict.reason}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (drift > 0) {
|
|
327
|
+
console.error(`board: regenerate with: node scripts/board.mjs --dir ${dir}`);
|
|
328
|
+
process.exit(1);
|
|
329
|
+
}
|
|
330
|
+
console.log(`board: projections up to date (3 files in ${outDir})`);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
writeAllAtomic(Object.entries(rendered.files).map(([name, content]) => [join(outDir, name), content]));
|
|
335
|
+
for (const name of Object.keys(rendered.files)) console.log(`wrote ${join(outDir, name)}`);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function canonicalPath(path) {
|
|
339
|
+
const abs = resolve(path);
|
|
340
|
+
try {
|
|
341
|
+
return realpathSync(abs);
|
|
342
|
+
} catch {
|
|
343
|
+
return abs;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function isMainModule(moduleUrl) {
|
|
348
|
+
if (!process.argv[1]) return false;
|
|
349
|
+
return canonicalPath(process.argv[1]) === canonicalPath(fileURLToPath(moduleUrl));
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (isMainModule(import.meta.url)) main();
|
package/scripts/doctor.mjs
CHANGED
|
@@ -45,6 +45,8 @@ import {
|
|
|
45
45
|
inline,
|
|
46
46
|
naturalCompare,
|
|
47
47
|
renderProjections,
|
|
48
|
+
BOARD_FILE,
|
|
49
|
+
BOARD_JSON_FILE,
|
|
48
50
|
PROGRESS_FILE,
|
|
49
51
|
STATE_FILE,
|
|
50
52
|
} from './project.mjs';
|
|
@@ -170,6 +172,7 @@ export const SEVERITY_BY_CODE = Object.freeze(
|
|
|
170
172
|
'projection-blocked': 'warning',
|
|
171
173
|
'projection-failed': 'error',
|
|
172
174
|
'projection-unreadable': 'error',
|
|
175
|
+
'board-absent': 'info',
|
|
173
176
|
// configuration
|
|
174
177
|
'config-missing': 'info',
|
|
175
178
|
'config-invalid': 'error',
|
|
@@ -903,6 +906,41 @@ function projectionFindings(journalPath, dir, at, read) {
|
|
|
903
906
|
),
|
|
904
907
|
);
|
|
905
908
|
}
|
|
909
|
+
// The board pair rides the same projection contract, with its own absent
|
|
910
|
+
// code: every install older than the board feature has neither file, and
|
|
911
|
+
// that must stay info — a check that fails on upgrade day gets deleted.
|
|
912
|
+
const boardNames = [BOARD_FILE, BOARD_JSON_FILE];
|
|
913
|
+
const boardPresent = boardNames.filter((name) => existsSync(join(dir, name)));
|
|
914
|
+
if (boardPresent.length === 0) {
|
|
915
|
+
findings.push(
|
|
916
|
+
finding(
|
|
917
|
+
'board-absent',
|
|
918
|
+
show(dir),
|
|
919
|
+
`no ${BOARD_FILE} / ${BOARD_JSON_FILE} yet — regenerating the projections creates them`,
|
|
920
|
+
regenerate,
|
|
921
|
+
),
|
|
922
|
+
);
|
|
923
|
+
return findings;
|
|
924
|
+
}
|
|
925
|
+
for (const name of boardNames) {
|
|
926
|
+
const path = join(dir, name);
|
|
927
|
+
if (!boardPresent.includes(name)) {
|
|
928
|
+
findings.push(
|
|
929
|
+
finding('projection-missing', show(path), `${name} is missing while ${boardPresent[0]} exists — a projection run stopped half way`, regenerate),
|
|
930
|
+
);
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
let result;
|
|
934
|
+
try {
|
|
935
|
+
result = checkFile(path, files[name]);
|
|
936
|
+
} catch (err) {
|
|
937
|
+
findings.push(finding('projection-unreadable', show(path), `cannot read the projection (${errText(err)})`));
|
|
938
|
+
continue;
|
|
939
|
+
}
|
|
940
|
+
if (!result.ok) {
|
|
941
|
+
findings.push(finding('projection-drift', show(path), `${name} does not match the journal (${result.reason})`, regenerate));
|
|
942
|
+
}
|
|
943
|
+
}
|
|
906
944
|
return findings;
|
|
907
945
|
}
|
|
908
946
|
|
|
@@ -1076,6 +1114,9 @@ export function trackedLeaseFiles(run, tyranDirName = '.tyran') {
|
|
|
1076
1114
|
}
|
|
1077
1115
|
|
|
1078
1116
|
/** The repo-global overnight runtime files that legally live at state/ level. */
|
|
1117
|
+
/** The cross-initiative board artefacts board.mjs writes at state/ level. */
|
|
1118
|
+
export const CROSS_BOARD_FILES = Object.freeze(['BOARD.md', 'board.json', 'board.html']);
|
|
1119
|
+
|
|
1079
1120
|
export const OVERNIGHT_RUNTIME_FILES = Object.freeze([
|
|
1080
1121
|
'paused-until.json',
|
|
1081
1122
|
'resume.json',
|
|
@@ -1304,6 +1345,7 @@ export function runStateChecks({ dir = '.tyran', now = null, staleHours = DEFAUL
|
|
|
1304
1345
|
// live at the state/ level by design (repo-global, machine-local,
|
|
1305
1346
|
// gitignored) and are checked by overnightFindings instead.
|
|
1306
1347
|
if (OVERNIGHT_RUNTIME_FILES.includes(name)) continue;
|
|
1348
|
+
if (CROSS_BOARD_FILES.includes(name)) continue; // generated by board.mjs at this level, by design
|
|
1307
1349
|
findings.push(
|
|
1308
1350
|
finding(
|
|
1309
1351
|
'state-stray-file',
|
package/scripts/project.mjs
CHANGED
|
@@ -29,18 +29,25 @@ import {
|
|
|
29
29
|
import { dirname, join, resolve } from 'node:path';
|
|
30
30
|
import { fileURLToPath } from 'node:url';
|
|
31
31
|
import { readJournal, pairSpawns } from './journal.mjs';
|
|
32
|
-
import { escapeInvisible } from './invisible.mjs';
|
|
32
|
+
import { escapeInvisible, jsonEscapeInvisible } from './invisible.mjs';
|
|
33
33
|
|
|
34
34
|
/** Projection file names. Both are fully generated — never hand-edited. */
|
|
35
35
|
export const STATE_FILE = 'STATE.md';
|
|
36
36
|
export const PROGRESS_FILE = 'PROGRESS.md';
|
|
37
|
+
export const BOARD_FILE = 'BOARD.md';
|
|
38
|
+
export const BOARD_JSON_FILE = 'board.json';
|
|
37
39
|
|
|
38
40
|
const GENERATED_HEADER =
|
|
39
41
|
'<!-- GENERATED by tyran scripts/project.mjs - DO NOT EDIT. Source of truth: journal.jsonl -->\n' +
|
|
40
42
|
'<!-- Regenerate: node scripts/project.mjs <journal.jsonl> --out-dir <dir> -->\n';
|
|
41
43
|
|
|
42
44
|
/** Gate results that count as closed. Anything else keeps the gate OPEN. */
|
|
43
|
-
const GATE_PASS = new Set(['pass', 'passed', 'ok', 'green', 'approved', 'closed']);
|
|
45
|
+
const GATE_PASS = new Set(['pass', 'passed', 'ok', 'green', 'approved', 'closed', 'answered']);
|
|
46
|
+
|
|
47
|
+
/** A gate result that means "a human owes an answer" — the board's queue. */
|
|
48
|
+
export const WAITING_RE = /^waiting[_-]?on[_-]?(operator|owner|human)$/i;
|
|
49
|
+
/** A gate kind that means "paused on the subscription window" (overnight mode). */
|
|
50
|
+
export const PAUSED_RE = /usage[-_]?limit/i;
|
|
44
51
|
|
|
45
52
|
/** Longest inline value rendered in a cell or list item, in codepoints. */
|
|
46
53
|
const MAX_CELL = 160;
|
|
@@ -260,6 +267,7 @@ export function fold({ events = [], truncatedTail = false, badLines = [] } = {})
|
|
|
260
267
|
findings: [],
|
|
261
268
|
// `ticket.status` events naming a ticket no other event mentions
|
|
262
269
|
unknownOverrides: [],
|
|
270
|
+
unknownErrorTickets: [],
|
|
263
271
|
};
|
|
264
272
|
|
|
265
273
|
/**
|
|
@@ -310,6 +318,7 @@ export function fold({ events = [], truncatedTail = false, badLines = [] } = {})
|
|
|
310
318
|
review: null,
|
|
311
319
|
merge: null,
|
|
312
320
|
override: null,
|
|
321
|
+
error: null,
|
|
313
322
|
lastTs: seenTs ?? null,
|
|
314
323
|
});
|
|
315
324
|
}
|
|
@@ -411,6 +420,7 @@ export function fold({ events = [], truncatedTail = false, badLines = [] } = {})
|
|
|
411
420
|
const t = ticketOf(data.ticket, ts);
|
|
412
421
|
t.report = { verdict: data.verdict ?? null, ts, by: data.agent ?? actor };
|
|
413
422
|
t.override = null; // a lifecycle event outranks a hand-set lane
|
|
423
|
+
t.error = null;
|
|
414
424
|
}
|
|
415
425
|
if (data.agent != null) closeAgent(state, data.agent);
|
|
416
426
|
break;
|
|
@@ -471,6 +481,13 @@ export function fold({ events = [], truncatedTail = false, badLines = [] } = {})
|
|
|
471
481
|
result: data.result ?? null,
|
|
472
482
|
ts,
|
|
473
483
|
evidence: data.evidence_ref ?? data.evidence ?? null,
|
|
484
|
+
// extra data keys are legal on append; the ask fields ride along so
|
|
485
|
+
// the board's waiting-operator queue can render the question with
|
|
486
|
+
// its recommendation and default (absent on ordinary gates).
|
|
487
|
+
ticket: data.ticket ?? null,
|
|
488
|
+
question: data.question ?? null,
|
|
489
|
+
recommendation: data.recommendation ?? null,
|
|
490
|
+
default: data.default ?? null,
|
|
474
491
|
count: (prev?.count ?? 0) + 1,
|
|
475
492
|
});
|
|
476
493
|
break;
|
|
@@ -482,6 +499,7 @@ export function fold({ events = [], truncatedTail = false, badLines = [] } = {})
|
|
|
482
499
|
const t = ticketOf(data.ticket ?? '(no ticket)', ts);
|
|
483
500
|
t.review = { verdict: data.verdict ?? null, by: data.by ?? actor, ts };
|
|
484
501
|
t.override = null;
|
|
502
|
+
t.error = null;
|
|
485
503
|
clearBlockagesOn(state, t.id);
|
|
486
504
|
// The review is the REVIEWER's completion event, as a report is the
|
|
487
505
|
// implementer's: pairSpawns closes the reviewer's spawn on `data.by`,
|
|
@@ -495,6 +513,7 @@ export function fold({ events = [], truncatedTail = false, badLines = [] } = {})
|
|
|
495
513
|
const t = ticketOf(data.ticket ?? '(no ticket)', ts);
|
|
496
514
|
t.merge = { sha: data.sha ?? null, mode: data.mode ?? null, ts };
|
|
497
515
|
t.override = null;
|
|
516
|
+
t.error = null;
|
|
498
517
|
clearBlockagesOn(state, t.id);
|
|
499
518
|
break;
|
|
500
519
|
}
|
|
@@ -520,9 +539,25 @@ export function fold({ events = [], truncatedTail = false, badLines = [] } = {})
|
|
|
520
539
|
case 'retro.entry':
|
|
521
540
|
state.retro.push({ kind: data.kind ?? null, target: data.target ?? null, confidence: data.confidence ?? null, ts });
|
|
522
541
|
break;
|
|
523
|
-
case 'error':
|
|
542
|
+
case 'error': {
|
|
524
543
|
state.errors.push({ class: data.class ?? null, detail: data.detail ?? null, ts, actor });
|
|
544
|
+
// `data.ticket` is optional metadata on an error, so a typo here is a
|
|
545
|
+
// typo nothing rejected at append. Binding it to a ticket the journal
|
|
546
|
+
// has never seen would MINT that ticket, and a minted ticket is one
|
|
547
|
+
// the denominator counts and no `merge` can ever close — the headline
|
|
548
|
+
// percent falls and never recovers. Same rule as `ticket.status`
|
|
549
|
+
// above, for the same reason; the error itself is still rendered in
|
|
550
|
+
// the Errors table either way, so nothing is lost by not binding it.
|
|
551
|
+
if (data.ticket != null) {
|
|
552
|
+
const key = String(data.ticket);
|
|
553
|
+
if (state.tickets.has(key)) {
|
|
554
|
+
ticketOf(key, ts).error = { class: data.class ?? null, detail: data.detail ?? null, ts };
|
|
555
|
+
} else {
|
|
556
|
+
state.unknownErrorTickets.push({ ticket: key, ts });
|
|
557
|
+
}
|
|
558
|
+
}
|
|
525
559
|
break;
|
|
560
|
+
}
|
|
526
561
|
default:
|
|
527
562
|
state.unknownTypes.set(ev, (state.unknownTypes.get(ev) ?? 0) + 1);
|
|
528
563
|
}
|
|
@@ -552,6 +587,215 @@ export function ticketStatus(t) {
|
|
|
552
587
|
return 'open';
|
|
553
588
|
}
|
|
554
589
|
|
|
590
|
+
// ------------------------------------------------------------------ board
|
|
591
|
+
|
|
592
|
+
/** Lane order, strongest verdicts first. The board renders one section per
|
|
593
|
+
* lane; a ticket lands in exactly ONE, by the precedence in `boardOf`. */
|
|
594
|
+
export const LANES = Object.freeze([
|
|
595
|
+
'waiting-operator',
|
|
596
|
+
'paused-limit',
|
|
597
|
+
'blocked',
|
|
598
|
+
'changes-requested',
|
|
599
|
+
'in-review',
|
|
600
|
+
'in-progress',
|
|
601
|
+
'ready',
|
|
602
|
+
'backlog',
|
|
603
|
+
'parked',
|
|
604
|
+
'done',
|
|
605
|
+
]);
|
|
606
|
+
|
|
607
|
+
const APPROVING_RE = /^approv|^lgtm$|^pass/i;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* The kanban view of a folded state. PURE and clock-free: every timestamp is
|
|
611
|
+
* copied from an event; "how old" is a question only the HTML viewer answers,
|
|
612
|
+
* client-side. A ticket is in exactly one lane, decided strongest-first:
|
|
613
|
+
*
|
|
614
|
+
* done (merge) > parked/waiting-operator/blocked (override) > blocked
|
|
615
|
+
* (open blockage or error) > paused-limit (an open usage-limit gate AND the
|
|
616
|
+
* ticket would otherwise be in progress) > changes-requested > in-review >
|
|
617
|
+
* in-progress > ready (all deps merged; an UNKNOWN dep counts unmet — a
|
|
618
|
+
* typo must refuse to schedule, not schedule) > backlog.
|
|
619
|
+
*/
|
|
620
|
+
export function boardOf(state) {
|
|
621
|
+
const lanes = new Map(LANES.map((lane) => [lane, []]));
|
|
622
|
+
const runningByTicket = new Map();
|
|
623
|
+
for (const a of state.agents) {
|
|
624
|
+
if (a.status === 'running' && a.ticket != null) {
|
|
625
|
+
runningByTicket.set(String(a.ticket), [...(runningByTicket.get(String(a.ticket)) ?? []), a.agent]);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
const mergedIds = new Set(state.ticketList.filter((t) => t.merge !== null).map((t) => t.id));
|
|
629
|
+
const knownIds = new Set(state.ticketList.map((t) => t.id));
|
|
630
|
+
const pausedGate = [...state.gates.values()].find(
|
|
631
|
+
(g) => PAUSED_RE.test(g.kind) && !GATE_PASS.has(String(g.result ?? '').toLowerCase()),
|
|
632
|
+
) ?? null;
|
|
633
|
+
|
|
634
|
+
const asks = [];
|
|
635
|
+
for (const g of state.openGates) {
|
|
636
|
+
if (WAITING_RE.test(String(g.result ?? ''))) {
|
|
637
|
+
asks.push({
|
|
638
|
+
kind: g.kind,
|
|
639
|
+
ticket: g.ticket ?? null,
|
|
640
|
+
question: g.question ?? null,
|
|
641
|
+
recommendation: g.recommendation ?? null,
|
|
642
|
+
default: g.default ?? null,
|
|
643
|
+
since: g.ts ?? null,
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
const askTickets = new Set(asks.filter((a) => a.ticket != null).map((a) => String(a.ticket)));
|
|
648
|
+
// Blockages are keyed by AGENT (one ticket can block several agents), so a
|
|
649
|
+
// ticket's blockage is found by scanning for its id, never by lookup.
|
|
650
|
+
const blockageOn = (ticketId) => {
|
|
651
|
+
for (const b of state.blockages.values()) if (b.ticket != null && String(b.ticket) === ticketId) return b;
|
|
652
|
+
return null;
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
for (const t of state.ticketList) {
|
|
656
|
+
const laneOf = () => {
|
|
657
|
+
if (t.merge) return 'done';
|
|
658
|
+
if (t.override?.column && LANES.includes(t.override.column)) return t.override.column;
|
|
659
|
+
if (askTickets.has(t.id)) return 'waiting-operator';
|
|
660
|
+
if (blockageOn(t.id) !== null || t.error !== null) return 'blocked';
|
|
661
|
+
const running = runningByTicket.get(t.id) ?? [];
|
|
662
|
+
if (pausedGate !== null && running.length > 0) return 'paused-limit';
|
|
663
|
+
if (t.review && !APPROVING_RE.test(String(t.review.verdict ?? ''))) return 'changes-requested';
|
|
664
|
+
if (t.review || t.report) return 'in-review';
|
|
665
|
+
if (running.length > 0) return 'in-progress';
|
|
666
|
+
const deps = Array.isArray(t.deps) ? t.deps.map(String) : [];
|
|
667
|
+
const unmet = deps.filter((d) => !mergedIds.has(d));
|
|
668
|
+
const unknown = deps.filter((d) => !knownIds.has(d));
|
|
669
|
+
if (deps.length === 0 || (unmet.length === 0 && unknown.length === 0)) return 'ready';
|
|
670
|
+
return 'backlog';
|
|
671
|
+
};
|
|
672
|
+
const lane = laneOf();
|
|
673
|
+
const deps = Array.isArray(t.deps) ? t.deps.map(String) : [];
|
|
674
|
+
const annotations = [];
|
|
675
|
+
if (lane === 'in-review' && t.review && APPROVING_RE.test(String(t.review.verdict ?? ''))) {
|
|
676
|
+
annotations.push('approved, awaiting merge');
|
|
677
|
+
}
|
|
678
|
+
if (lane === 'blocked') {
|
|
679
|
+
const b = blockageOn(t.id);
|
|
680
|
+
if (b) annotations.push(b.detail ?? 'blocked');
|
|
681
|
+
else if (t.error) annotations.push(`error: ${t.error.class ?? 'unknown'}`);
|
|
682
|
+
}
|
|
683
|
+
if (t.override) annotations.push(t.override.reason ?? 'set by ticket.status');
|
|
684
|
+
if (lane === 'backlog') {
|
|
685
|
+
for (const d of deps.filter((x) => !knownIds.has(x))) annotations.push(`dep ${d} (unknown)`);
|
|
686
|
+
}
|
|
687
|
+
lanes.get(lane).push({
|
|
688
|
+
id: t.id,
|
|
689
|
+
title: t.title,
|
|
690
|
+
agents: runningByTicket.get(t.id) ?? [],
|
|
691
|
+
since: t.lastTs,
|
|
692
|
+
annotation: annotations.length > 0 ? annotations.join(' · ') : null,
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
const agents = state.agents
|
|
697
|
+
.filter((a) => a.status === 'running')
|
|
698
|
+
.map((a) => {
|
|
699
|
+
const signal = state.progressByAgent.get(a.agent) ?? null;
|
|
700
|
+
return {
|
|
701
|
+
agent: a.agent,
|
|
702
|
+
role: a.role,
|
|
703
|
+
ticket: a.ticket,
|
|
704
|
+
state: signal?.state ?? 'running',
|
|
705
|
+
detail: signal?.detail ?? null,
|
|
706
|
+
next: signal?.next ?? null,
|
|
707
|
+
last_signal: signal?.ts ?? a.spawnTs,
|
|
708
|
+
};
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
return {
|
|
712
|
+
lanes,
|
|
713
|
+
asks,
|
|
714
|
+
agents,
|
|
715
|
+
paused: pausedGate === null
|
|
716
|
+
? null
|
|
717
|
+
: { kind: pausedGate.kind, result: pausedGate.result, since: pausedGate.ts ?? null },
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/** BOARD.md — the waiting queue first, then the agent strip, then the lanes. */
|
|
722
|
+
export function renderBoard(state, board = boardOf(state)) {
|
|
723
|
+
const parts = [GENERATED_HEADER, `# BOARD — ${inline(state.initiatives)}\n\n`];
|
|
724
|
+
parts.push(`**Progress:** ${progressLine(state)}\n`);
|
|
725
|
+
if (board.paused !== null) {
|
|
726
|
+
parts.push(`\n**PAUSED** on gate ${inline(board.paused.kind)} (${inline(board.paused.result)}) since ${inline(board.paused.since)}\n`);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
parts.push('\n## Waiting on operator\n\n');
|
|
730
|
+
parts.push(
|
|
731
|
+
table(
|
|
732
|
+
['Question', 'Recommendation', 'Default', 'Ticket', 'Gate', 'Since'],
|
|
733
|
+
board.asks.map((a) => [
|
|
734
|
+
inline(a.question ?? '(no question recorded)'),
|
|
735
|
+
inline(a.recommendation),
|
|
736
|
+
inline(a.default),
|
|
737
|
+
inline(a.ticket),
|
|
738
|
+
inline(a.kind),
|
|
739
|
+
inline(a.since),
|
|
740
|
+
]),
|
|
741
|
+
),
|
|
742
|
+
);
|
|
743
|
+
|
|
744
|
+
parts.push('\n## Agents\n\n');
|
|
745
|
+
parts.push(
|
|
746
|
+
table(
|
|
747
|
+
['Agent', 'Role', 'Ticket', 'State', 'Detail', 'Last signal'],
|
|
748
|
+
sortByKey(board.agents, (a) => a.agent).map((a) => [
|
|
749
|
+
inline(a.agent),
|
|
750
|
+
inline(a.role),
|
|
751
|
+
inline(a.ticket),
|
|
752
|
+
inline(a.state),
|
|
753
|
+
inline(a.detail),
|
|
754
|
+
inline(a.last_signal),
|
|
755
|
+
]),
|
|
756
|
+
),
|
|
757
|
+
);
|
|
758
|
+
|
|
759
|
+
for (const lane of LANES) {
|
|
760
|
+
const cards = board.lanes.get(lane);
|
|
761
|
+
parts.push(`\n## ${lane} (${cards.length})\n\n`);
|
|
762
|
+
parts.push(
|
|
763
|
+
list(
|
|
764
|
+
cards.map(
|
|
765
|
+
(c) =>
|
|
766
|
+
`\`${inline(c.id)}\`${c.title ? ` — ${inline(c.title)}` : ''}` +
|
|
767
|
+
`${c.agents.length > 0 ? ` — ${inline(c.agents)}` : ''}` +
|
|
768
|
+
`${c.annotation ? ` _(${inline(c.annotation)})_` : ''}`,
|
|
769
|
+
),
|
|
770
|
+
),
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
return parts.join('');
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* board.json, schema 1. Deterministic: fixed key insertion order, timestamps
|
|
778
|
+
* verbatim from events, invisibles escaped as \uXXXX (round-trips through
|
|
779
|
+
* JSON.parse) — silent removal is the one thing this layer refuses to do.
|
|
780
|
+
*/
|
|
781
|
+
export function boardJson(state, board = boardOf(state)) {
|
|
782
|
+
const payload = {
|
|
783
|
+
schema: 1,
|
|
784
|
+
initiative: state.initiatives.length === 1 ? state.initiatives[0] : state.initiatives,
|
|
785
|
+
progress: {
|
|
786
|
+
percent: state.percent,
|
|
787
|
+
merged: state.merged,
|
|
788
|
+
tickets: state.ticketList.length,
|
|
789
|
+
phase: state.checkpoint?.phase ?? null,
|
|
790
|
+
},
|
|
791
|
+
paused: board.paused,
|
|
792
|
+
asks: board.asks,
|
|
793
|
+
agents: sortByKey(board.agents, (a) => a.agent),
|
|
794
|
+
lanes: Object.fromEntries(LANES.map((lane) => [lane, board.lanes.get(lane)])),
|
|
795
|
+
};
|
|
796
|
+
return jsonEscapeInvisible(JSON.stringify(payload, null, 2)) + '\n';
|
|
797
|
+
}
|
|
798
|
+
|
|
555
799
|
/** The one-line progress banner; also the H1 of PROGRESS.md. */
|
|
556
800
|
export function progressLine(state) {
|
|
557
801
|
const phase = state.checkpoint?.phase ?? null;
|
|
@@ -594,6 +838,9 @@ export function warnings(state) {
|
|
|
594
838
|
for (const { ticket } of state.unknownOverrides) {
|
|
595
839
|
out.push(`ticket.status for unknown ticket "${inlinePlain(ticket)}" — ignored (an override never invents a ticket)`);
|
|
596
840
|
}
|
|
841
|
+
for (const { ticket } of state.unknownErrorTickets) {
|
|
842
|
+
out.push(`error names unknown ticket "${inlinePlain(ticket)}" — the error is recorded, but not bound to a ticket`);
|
|
843
|
+
}
|
|
597
844
|
if (state.initiatives.length > 1) {
|
|
598
845
|
out.push(
|
|
599
846
|
`journal mixes ${state.initiatives.length} initiatives: ${state.initiatives.map((i) => inlinePlain(i)).join(', ')}`,
|
|
@@ -872,10 +1119,16 @@ function renderProgress(state) {
|
|
|
872
1119
|
*/
|
|
873
1120
|
export function renderProjections(readResult) {
|
|
874
1121
|
const state = fold(readResult);
|
|
1122
|
+
const board = boardOf(state);
|
|
875
1123
|
return {
|
|
876
1124
|
state,
|
|
877
1125
|
warnings: warnings(state),
|
|
878
|
-
files: {
|
|
1126
|
+
files: {
|
|
1127
|
+
[STATE_FILE]: renderState(state),
|
|
1128
|
+
[PROGRESS_FILE]: renderProgress(state),
|
|
1129
|
+
[BOARD_FILE]: renderBoard(state, board),
|
|
1130
|
+
[BOARD_JSON_FILE]: boardJson(state, board),
|
|
1131
|
+
},
|
|
879
1132
|
};
|
|
880
1133
|
}
|
|
881
1134
|
|
package/skills/run/SKILL.md
CHANGED
|
@@ -138,8 +138,11 @@ open one.
|
|
|
138
138
|
`.tyran/state/<initiative>/journal.jsonl`:
|
|
139
139
|
`node ${CLAUDE_PLUGIN_ROOT}/scripts/journal.mjs append <journal> <event>
|
|
140
140
|
<initiative> --actor conductor --data '{...}'`. Regenerate the readable
|
|
141
|
-
views with `scripts/project.mjs
|
|
142
|
-
|
|
141
|
+
views with `scripts/project.mjs` at every merge — `BOARD.md` and
|
|
142
|
+
`board.json` are part of the set — and the cross-initiative board with
|
|
143
|
+
`scripts/board.mjs`; every one of them is GENERATED — never hand-edit.
|
|
144
|
+
Moving a ticket on the board IS appending an event; there is no other way.
|
|
145
|
+
Authored, alongside the journal:
|
|
143
146
|
`PLAN.md` (decomposition plus the **manifest of
|
|
144
147
|
shared zones**) and `NOTES.md` (side observations, defaults you adopted,
|
|
145
148
|
and **signals about the PROCESS itself**: what slowed the work, what the
|
package/skills/status/SKILL.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Where is the work right now. Regenerates
|
|
2
|
+
description: Where is the work right now. Regenerates the projections and the kanban board from the journal and answers with the progress line, the agents still running, the open gates and the resume steps. Read-only. Use for /tyran:status or when asked what is going on.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
# Status
|
|
@@ -9,6 +9,7 @@ Answer from the journal, never from memory.
|
|
|
9
9
|
```bash
|
|
10
10
|
J=$(ls -t .tyran/state/*/journal.jsonl 2>/dev/null | head -1)
|
|
11
11
|
node "${CLAUDE_PLUGIN_ROOT}/scripts/project.mjs" "$J" --out-dir "$(dirname "$J")"
|
|
12
|
+
node "${CLAUDE_PLUGIN_ROOT}/scripts/board.mjs" --dir .tyran
|
|
12
13
|
node "${CLAUDE_PLUGIN_ROOT}/scripts/journal.mjs" tail "$J"
|
|
13
14
|
node "${CLAUDE_PLUGIN_ROOT}/scripts/journal.mjs" open-spawns "$J"
|
|
14
15
|
```
|
|
@@ -28,6 +29,9 @@ Then report, in this order and no longer than a screen:
|
|
|
28
29
|
these; they mean two agents believed they owned the same worktree.
|
|
29
30
|
6. The resume steps from the last checkpoint.
|
|
30
31
|
|
|
32
|
+
End by pointing the operator at `.tyran/state/board.html` — the kanban view
|
|
33
|
+
of everything above, refreshed on every subagent stop and every merge.
|
|
34
|
+
|
|
31
35
|
If there is no journal, say exactly that and suggest `/tyran:setup`. Do not
|
|
32
36
|
reconstruct a status from the git log — a plausible status is worse than none,
|
|
33
37
|
because it will be believed.
|