@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/scripts/board.mjs
CHANGED
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
} from './project.mjs';
|
|
42
42
|
import { jsonEscapeInvisible } from './invisible.mjs';
|
|
43
43
|
import { renderBoardHtml } from './board-html.mjs';
|
|
44
|
+
import { COST_SCHEMA, costJson, costReport } from './cost.mjs';
|
|
44
45
|
|
|
45
46
|
export const BOARD_HTML_FILE = 'board.html';
|
|
46
47
|
|
|
@@ -261,8 +262,14 @@ function main() {
|
|
|
261
262
|
const outDir = join(dir, 'state');
|
|
262
263
|
|
|
263
264
|
if (flags.serve) {
|
|
264
|
-
//
|
|
265
|
-
//
|
|
265
|
+
// Loopback-only, re-rendered per request so it is always fresh. No
|
|
266
|
+
// filesystem path is ever derived from the URL.
|
|
267
|
+
//
|
|
268
|
+
// Not quite read-only, and the exception is worth stating rather than
|
|
269
|
+
// discovering: `/cost.json` refreshes the machine-local spend cache at
|
|
270
|
+
// `state/cost.json`. Nothing else is written, and that file is a
|
|
271
|
+
// gitignored runtime artefact — no journal, no projection, nothing
|
|
272
|
+
// committed.
|
|
266
273
|
const server = createServer((req, res) => {
|
|
267
274
|
try {
|
|
268
275
|
// Binding to loopback is not enough on its own: any web page the
|
|
@@ -277,6 +284,28 @@ function main() {
|
|
|
277
284
|
res.end('forbidden: this board answers to 127.0.0.1 only\n');
|
|
278
285
|
return;
|
|
279
286
|
}
|
|
287
|
+
// Spend is served, never rendered into the artefacts. It is derived
|
|
288
|
+
// from transcripts under the operator's home directory — machine-local
|
|
289
|
+
// by nature — so putting it in board.json would make two clones of one
|
|
290
|
+
// journal disagree and break the byte-exact `--check` contract. The
|
|
291
|
+
// page fetches this route and simply omits the section when the fetch
|
|
292
|
+
// fails, which is what happens over file://.
|
|
293
|
+
if (req.url === '/cost.json') {
|
|
294
|
+
let body;
|
|
295
|
+
try {
|
|
296
|
+
body = costJson(costReport({ tyranDir: dir }));
|
|
297
|
+
} catch (err) {
|
|
298
|
+
// A cost failure must never take the board down with it: the
|
|
299
|
+
// board answers "what is going on", and that answer does not
|
|
300
|
+
// depend on knowing what it cost.
|
|
301
|
+
res.writeHead(503, { 'content-type': 'application/json; charset=utf-8' });
|
|
302
|
+
res.end(JSON.stringify({ schema: COST_SCHEMA, error: String(err?.message ?? err) }) + '\n');
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
res.writeHead(200, { 'content-type': 'application/json; charset=utf-8' });
|
|
306
|
+
res.end(body);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
280
309
|
const { files } = renderAll(dir);
|
|
281
310
|
if (req.url === '/' || req.url === '/index.html') {
|
|
282
311
|
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
|