@fnndsc/brasa 0.31.4 → 0.32.0
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/dist/buildinfo.json +1 -1
- package/dist/builtins/fs/pull.js +16 -0
- package/dist/builtins/fs/pull.js.map +1 -1
- package/dist/builtins/games/bytes.d.ts +21 -0
- package/dist/builtins/games/bytes.js +224 -0
- package/dist/builtins/games/bytes.js.map +1 -0
- package/dist/builtins/games/chimes.d.ts +64 -0
- package/dist/builtins/games/chimes.js +223 -0
- package/dist/builtins/games/chimes.js.map +1 -0
- package/dist/builtins/games/cowsay.d.ts +36 -0
- package/dist/builtins/games/cowsay.js +127 -0
- package/dist/builtins/games/cowsay.js.map +1 -0
- package/dist/builtins/games/figlet.d.ts +25 -0
- package/dist/builtins/games/figlet.js +109 -0
- package/dist/builtins/games/figlet.js.map +1 -0
- package/dist/builtins/games/lab.d.ts +51 -0
- package/dist/builtins/games/lab.js +161 -0
- package/dist/builtins/games/lab.js.map +1 -0
- package/dist/builtins/games/lolcat.d.ts +26 -0
- package/dist/builtins/games/lolcat.js +71 -0
- package/dist/builtins/games/lolcat.js.map +1 -0
- package/dist/builtins/games/morse.d.ts +18 -0
- package/dist/builtins/games/morse.js +46 -0
- package/dist/builtins/games/morse.js.map +1 -0
- package/dist/builtins/games/numbers.d.ts +55 -0
- package/dist/builtins/games/numbers.js +270 -0
- package/dist/builtins/games/numbers.js.map +1 -0
- package/dist/builtins/games/play.d.ts +53 -0
- package/dist/builtins/games/play.js +228 -0
- package/dist/builtins/games/play.js.map +1 -0
- package/dist/builtins/games/qr.d.ts +40 -0
- package/dist/builtins/games/qr.js +336 -0
- package/dist/builtins/games/qr.js.map +1 -0
- package/dist/builtins/games/shelf.d.ts +27 -0
- package/dist/builtins/games/shelf.js +71 -0
- package/dist/builtins/games/shelf.js.map +1 -0
- package/dist/builtins/games/show.d.ts +32 -0
- package/dist/builtins/games/show.js +68 -0
- package/dist/builtins/games/show.js.map +1 -0
- package/dist/builtins/games/sky.d.ts +69 -0
- package/dist/builtins/games/sky.js +190 -0
- package/dist/builtins/games/sky.js.map +1 -0
- package/dist/builtins/games/stdin.d.ts +34 -0
- package/dist/builtins/games/stdin.js +48 -0
- package/dist/builtins/games/stdin.js.map +1 -0
- package/dist/builtins/games/text.d.ts +46 -0
- package/dist/builtins/games/text.js +133 -0
- package/dist/builtins/games/text.js.map +1 -0
- package/dist/builtins/games/wtf.d.ts +13 -0
- package/dist/builtins/games/wtf.data.d.ts +12 -0
- package/dist/builtins/games/wtf.data.js +70 -0
- package/dist/builtins/games/wtf.data.js.map +1 -0
- package/dist/builtins/games/wtf.js +45 -0
- package/dist/builtins/games/wtf.js.map +1 -0
- package/dist/builtins/help.d.ts +8 -0
- package/dist/builtins/help.js +296 -0
- package/dist/builtins/help.js.map +1 -1
- package/dist/core/dispatch.js +125 -9
- package/dist/core/dispatch.js.map +1 -1
- package/dist/core/engine.js +1 -0
- package/dist/core/engine.js.map +1 -1
- package/dist/core/surface.d.ts +14 -0
- package/dist/core/surface.js.map +1 -1
- package/dist/lib/vfs/providers/static.js +15 -1
- package/dist/lib/vfs/providers/static.js.map +1 -1
- package/dist/lib/vfs/providers/static_content.js +2 -2
- package/dist/lib/vfs/providers/static_content.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Time and sky from the shelf: `pom`, `stardate`, `ddate`, `sunrise`.
|
|
3
|
+
*
|
|
4
|
+
* `pom` is BSD's phase of the moon; `stardate` reckons the day two ways;
|
|
5
|
+
* `ddate` is the Discordian calendar, holy days included; `sunrise` asks
|
|
6
|
+
* Open-Meteo (the service `weather` already uses, no key) when the sun
|
|
7
|
+
* rises and sets at a place.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { envelope_ok, envelope_error } from '@fnndsc/cumin';
|
|
12
|
+
import chalk from 'chalk';
|
|
13
|
+
import { WEATHER_DEFAULT_PLACE, place_find } from '../sys/weather.js';
|
|
14
|
+
/* --------------------------------------------------------------- moon */
|
|
15
|
+
/** A reference new moon: 2000-01-06 18:14 UTC, as a Julian day. */
|
|
16
|
+
const NEW_MOON_JD = 2451550.1;
|
|
17
|
+
/** The synodic month, in days. */
|
|
18
|
+
const SYNODIC_DAYS = 29.530588853;
|
|
19
|
+
/** A date as a Julian day. */
|
|
20
|
+
export function julianDay_of(date) {
|
|
21
|
+
return date.getTime() / 86_400_000 + 2440587.5;
|
|
22
|
+
}
|
|
23
|
+
/** Where the moon stands on a date. */
|
|
24
|
+
export function moon_phase(date) {
|
|
25
|
+
const cycles = (julianDay_of(date) - NEW_MOON_JD) / SYNODIC_DAYS;
|
|
26
|
+
const phase = cycles - Math.floor(cycles);
|
|
27
|
+
const illumination = (1 - Math.cos(2 * Math.PI * phase)) / 2;
|
|
28
|
+
const near = (p) => Math.abs(phase - p) < 0.034 || Math.abs(phase - p - 1) < 0.034;
|
|
29
|
+
const name = near(0) ? 'New Moon' : near(0.25) ? 'First Quarter' : near(0.5) ? 'Full Moon' : near(0.75) ? 'Last Quarter'
|
|
30
|
+
: phase < 0.25 ? 'Waxing Crescent' : phase < 0.5 ? 'Waxing Gibbous' : phase < 0.75 ? 'Waning Gibbous' : 'Waning Crescent';
|
|
31
|
+
const toFull = ((0.5 - phase + 1) % 1) * SYNODIC_DAYS;
|
|
32
|
+
const toNew = ((1 - phase) % 1) * SYNODIC_DAYS;
|
|
33
|
+
return { phase, illumination, name, toFull, toNew };
|
|
34
|
+
}
|
|
35
|
+
/** A small moon, lit from the side the phase lights. */
|
|
36
|
+
export function moon_draw(phase) {
|
|
37
|
+
const lit = phase.illumination;
|
|
38
|
+
const waxing = phase.phase < 0.5;
|
|
39
|
+
const rows = [];
|
|
40
|
+
const radius = 4;
|
|
41
|
+
for (let y = -radius; y <= radius; y++) {
|
|
42
|
+
let row = '';
|
|
43
|
+
for (let x = -radius * 2; x <= radius * 2; x++) {
|
|
44
|
+
const dx = x / 2;
|
|
45
|
+
const inside = dx * dx + y * y <= radius * radius + 0.5;
|
|
46
|
+
if (!inside) {
|
|
47
|
+
row += ' ';
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const half = Math.sqrt(Math.max(0, radius * radius - y * y));
|
|
51
|
+
// The terminator: a chord moving across the disc as the phase goes.
|
|
52
|
+
const edge = (1 - 2 * lit) * half;
|
|
53
|
+
const bright = waxing ? dx >= edge : dx <= -edge;
|
|
54
|
+
row += bright ? '@' : '.';
|
|
55
|
+
}
|
|
56
|
+
rows.push(row.trimEnd());
|
|
57
|
+
}
|
|
58
|
+
return rows;
|
|
59
|
+
}
|
|
60
|
+
/** `pom [YYYY-MM-DD]` */
|
|
61
|
+
export async function builtin_pom(args) {
|
|
62
|
+
const date = args.length > 0 ? new Date(args.join(' ')) : new Date();
|
|
63
|
+
if (Number.isNaN(date.getTime()))
|
|
64
|
+
return envelope_error('', undefined, `pom: '${args.join(' ')}' is not a date (try pom 2026-12-25)\n`);
|
|
65
|
+
const moon = moon_phase(date);
|
|
66
|
+
const percent = Math.round(moon.illumination * 100);
|
|
67
|
+
const trend = moon.name === 'Full Moon' || moon.name === 'New Moon' ? '' : moon.phase < 0.5 ? ' (waxing)' : ' (waning)';
|
|
68
|
+
const lines = [
|
|
69
|
+
`The Moon is ${chalk.bold(moon.name)}${trend}: ${percent}% of the Full`,
|
|
70
|
+
`${chalk.gray(`next full moon in ${moon.toFull.toFixed(1)} days, next new moon in ${moon.toNew.toFixed(1)} days`)}`,
|
|
71
|
+
...moon_draw(moon).map((row) => ` ${row}`),
|
|
72
|
+
];
|
|
73
|
+
return envelope_ok(`${lines.join('\n')}\n`, { kind: 'games.pom', data: { date: date.toISOString(), ...moon } });
|
|
74
|
+
}
|
|
75
|
+
/* ----------------------------------------------------------- stardate */
|
|
76
|
+
/** Days into the year, 1-based, and the year's length. */
|
|
77
|
+
function yearDay_of(date) {
|
|
78
|
+
const start = Date.UTC(date.getUTCFullYear(), 0, 1);
|
|
79
|
+
const next = Date.UTC(date.getUTCFullYear() + 1, 0, 1);
|
|
80
|
+
const elapsed = date.getTime() - start;
|
|
81
|
+
const days = Math.round((next - start) / 86_400_000);
|
|
82
|
+
return { day: Math.floor(elapsed / 86_400_000) + 1, days, fraction: elapsed / (next - start) };
|
|
83
|
+
}
|
|
84
|
+
/** The stardate two ways: the Kelvin films' `YYYY.DDD`, and TNG's thousand-per-year from 2323. */
|
|
85
|
+
export function stardate_of(date) {
|
|
86
|
+
const { day, fraction } = yearDay_of(date);
|
|
87
|
+
const year = date.getUTCFullYear();
|
|
88
|
+
const kelvin = `${year}.${String(day).padStart(3, '0')}`;
|
|
89
|
+
const tng = (year - 2323) * 1000 + fraction * 1000;
|
|
90
|
+
return { kelvin, tng: tng.toFixed(1) };
|
|
91
|
+
}
|
|
92
|
+
/** `stardate` */
|
|
93
|
+
export async function builtin_stardate(args) {
|
|
94
|
+
const date = args.length > 0 ? new Date(args.join(' ')) : new Date();
|
|
95
|
+
if (Number.isNaN(date.getTime()))
|
|
96
|
+
return envelope_error('', undefined, `stardate: '${args.join(' ')}' is not a date\n`);
|
|
97
|
+
const sd = stardate_of(date);
|
|
98
|
+
const lines = [
|
|
99
|
+
`Stardate ${chalk.bold(sd.kelvin)}`,
|
|
100
|
+
chalk.gray(`(Kelvin reckoning: the year and the day of it; by TNG's count it is ${sd.tng} — that era is still ahead of us)`),
|
|
101
|
+
];
|
|
102
|
+
return envelope_ok(`${lines.join('\n')}\n`, { kind: 'games.stardate', data: { date: date.toISOString(), ...sd } });
|
|
103
|
+
}
|
|
104
|
+
/* -------------------------------------------------------------- ddate */
|
|
105
|
+
const SEASONS = ['Chaos', 'Discord', 'Confusion', 'Bureaucracy', 'The Aftermath'];
|
|
106
|
+
const WEEKDAYS = ['Sweetmorn', 'Boomtime', 'Pungenday', 'Prickle-Prickle', 'Setting Orange'];
|
|
107
|
+
const APOSTLE_DAYS = ['Mungday', 'Mojoday', 'Syaday', 'Zaraday', 'Maladay'];
|
|
108
|
+
const SEASON_DAYS = ['Chaoflux', 'Discoflux', 'Confuflux', 'Bureflux', 'Afflux'];
|
|
109
|
+
export function ddate_of(date) {
|
|
110
|
+
const year = date.getFullYear();
|
|
111
|
+
const yold = year + 1166;
|
|
112
|
+
const start = new Date(year, 0, 1);
|
|
113
|
+
const doy = Math.round((new Date(year, date.getMonth(), date.getDate()).getTime() - start.getTime()) / 86_400_000) + 1;
|
|
114
|
+
const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
115
|
+
if (leap && doy === 60)
|
|
116
|
+
return { yold, season: 'Chaos', day: 0, weekday: '', holyday: "St. Tib's Day", tibs: true };
|
|
117
|
+
const adjusted = leap && doy > 60 ? doy - 1 : doy;
|
|
118
|
+
const season = Math.floor((adjusted - 1) / 73);
|
|
119
|
+
const day = ((adjusted - 1) % 73) + 1;
|
|
120
|
+
const weekday = WEEKDAYS[(adjusted - 1) % 5];
|
|
121
|
+
const holyday = day === 5 ? APOSTLE_DAYS[season] : day === 50 ? SEASON_DAYS[season] : null;
|
|
122
|
+
return { yold, season: SEASONS[season], day, weekday, holyday, tibs: false };
|
|
123
|
+
}
|
|
124
|
+
/** 1st, 2nd, 3rd, 4th … 11th, 12th, 13th … 21st. */
|
|
125
|
+
export function ordinal_of(n) {
|
|
126
|
+
const rest = n % 100;
|
|
127
|
+
if (rest >= 11 && rest <= 13)
|
|
128
|
+
return `${n}th`;
|
|
129
|
+
return `${n}${['th', 'st', 'nd', 'rd'][n % 10] ?? 'th'}`;
|
|
130
|
+
}
|
|
131
|
+
/** `ddate [YYYY-MM-DD]` */
|
|
132
|
+
export async function builtin_ddate(args) {
|
|
133
|
+
const date = args.length > 0 ? new Date(args.join(' ')) : new Date();
|
|
134
|
+
if (Number.isNaN(date.getTime()))
|
|
135
|
+
return envelope_error('', undefined, `ddate: '${args.join(' ')}' is not a date\n`);
|
|
136
|
+
const d = ddate_of(date);
|
|
137
|
+
const line = d.tibs
|
|
138
|
+
? `Today is St. Tib's Day in the YOLD ${d.yold}`
|
|
139
|
+
: `Today is ${d.weekday}, the ${ordinal_of(d.day)} day of ${d.season} in the YOLD ${d.yold}${d.holyday === null ? '' : `\nCelebrate ${d.holyday}!`}`;
|
|
140
|
+
return envelope_ok(`${line}\n`, { kind: 'games.ddate', data: { date: date.toISOString(), ...d } });
|
|
141
|
+
}
|
|
142
|
+
/* ------------------------------------------------------------ sunrise */
|
|
143
|
+
const FORECAST_URL = 'https://api.open-meteo.com/v1/forecast';
|
|
144
|
+
const FETCH_TIMEOUT_MS = 8_000;
|
|
145
|
+
/**
|
|
146
|
+
* Asks Open-Meteo when the sun rises and sets at a place, today and tomorrow.
|
|
147
|
+
*
|
|
148
|
+
* @param fetchFn - The fetch to use.
|
|
149
|
+
* @param place - Where.
|
|
150
|
+
*/
|
|
151
|
+
export async function sun_fetch(fetchFn, place) {
|
|
152
|
+
const url = `${FORECAST_URL}?latitude=${place.latitude}&longitude=${place.longitude}&daily=sunrise,sunset,daylight_duration&timezone=auto&forecast_days=2`;
|
|
153
|
+
const response = await fetchFn(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
154
|
+
if (!response.ok)
|
|
155
|
+
throw new Error(`open-meteo answered ${response.status}`);
|
|
156
|
+
const answer = (await response.json());
|
|
157
|
+
const daily = answer.daily ?? {};
|
|
158
|
+
return (daily.time ?? []).map((date, i) => ({
|
|
159
|
+
date,
|
|
160
|
+
sunrise: daily.sunrise?.[i] ?? '',
|
|
161
|
+
sunset: daily.sunset?.[i] ?? '',
|
|
162
|
+
daylightSeconds: daily.daylight_duration?.[i] ?? 0,
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
/** `HH:MM` out of an ISO local time. */
|
|
166
|
+
const clock_of = (iso) => iso.slice(11, 16) || '?';
|
|
167
|
+
/** `sunrise [place]` */
|
|
168
|
+
export async function builtin_sunrise(args, fetchFn = (url, init) => fetch(url, init)) {
|
|
169
|
+
const name = args.length > 0 ? args.join(' ') : WEATHER_DEFAULT_PLACE;
|
|
170
|
+
try {
|
|
171
|
+
const place = await place_find(fetchFn, name);
|
|
172
|
+
if (place === null)
|
|
173
|
+
return envelope_error('', undefined, `sunrise: no place called '${name}' that open-meteo knows\n`);
|
|
174
|
+
const days = await sun_fetch(fetchFn, place);
|
|
175
|
+
if (days.length === 0)
|
|
176
|
+
return envelope_error('', undefined, `sunrise: open-meteo had no days for ${place.name}\n`);
|
|
177
|
+
const where = [place.name, place.region, place.country].filter((p) => p.length > 0).join(', ');
|
|
178
|
+
const lines = [chalk.bold(where)];
|
|
179
|
+
for (const [i, day] of days.entries()) {
|
|
180
|
+
const hours = Math.floor(day.daylightSeconds / 3600);
|
|
181
|
+
const minutes = Math.round((day.daylightSeconds % 3600) / 60);
|
|
182
|
+
lines.push(`${i === 0 ? 'today ' : 'tomorrow'} ${day.date} sunrise ${chalk.yellow(clock_of(day.sunrise))} sunset ${chalk.yellow(clock_of(day.sunset))} ${chalk.gray(`${hours}h ${String(minutes).padStart(2, '0')}m of daylight`)}`);
|
|
183
|
+
}
|
|
184
|
+
return envelope_ok(`${lines.join('\n')}\n`, { kind: 'games.sunrise', data: { place, days } });
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
return envelope_error('', undefined, `sunrise: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=sky.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sky.js","sourceRoot":"","sources":["../../../src/builtins/games/sky.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAwC,MAAM,mBAAmB,CAAC;AAE5G,0EAA0E;AAE1E,mEA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MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAC5O,CAAC;QACD,OAAO,WAAW,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,YAAY,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/G,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file What a piped builtin reads: the text the segment before it wrote.
|
|
3
|
+
*
|
|
4
|
+
* A pipeline's first segment always ran in the kernel; the rest went to the
|
|
5
|
+
* surface's host shell, so `fortune | cowsay` reached the host's cowsay (or,
|
|
6
|
+
* in a browser, nothing). A segment that names a builtin now runs in the
|
|
7
|
+
* kernel too, and reads what came before it here. The slot is set by the
|
|
8
|
+
* pipe for the length of one segment and taken by the builtin that wants
|
|
9
|
+
* it; a builtin that does not read it leaves it to be cleared, as a shell
|
|
10
|
+
* command that ignores stdin does.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Sets what the next builtin may read; the pipe calls this before a segment
|
|
16
|
+
* and clears it after.
|
|
17
|
+
*
|
|
18
|
+
* @param text - The previous segment's output, or null for none.
|
|
19
|
+
*/
|
|
20
|
+
export declare function stdin_set(text: string | null): void;
|
|
21
|
+
/**
|
|
22
|
+
* Takes the piped text, once.
|
|
23
|
+
*
|
|
24
|
+
* @returns The text, or null when the builtin was not piped into.
|
|
25
|
+
*/
|
|
26
|
+
export declare function stdin_take(): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* The text a toy works on: what was piped in, else its arguments joined,
|
|
29
|
+
* else nothing.
|
|
30
|
+
*
|
|
31
|
+
* @param args - The builtin's arguments.
|
|
32
|
+
* @returns The text, or null when there is none either way.
|
|
33
|
+
*/
|
|
34
|
+
export declare function text_input(args: ReadonlyArray<string>): string | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file What a piped builtin reads: the text the segment before it wrote.
|
|
3
|
+
*
|
|
4
|
+
* A pipeline's first segment always ran in the kernel; the rest went to the
|
|
5
|
+
* surface's host shell, so `fortune | cowsay` reached the host's cowsay (or,
|
|
6
|
+
* in a browser, nothing). A segment that names a builtin now runs in the
|
|
7
|
+
* kernel too, and reads what came before it here. The slot is set by the
|
|
8
|
+
* pipe for the length of one segment and taken by the builtin that wants
|
|
9
|
+
* it; a builtin that does not read it leaves it to be cleared, as a shell
|
|
10
|
+
* command that ignores stdin does.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/** The text piped into the segment now running, or null when nothing was. */
|
|
15
|
+
let piped = null;
|
|
16
|
+
/**
|
|
17
|
+
* Sets what the next builtin may read; the pipe calls this before a segment
|
|
18
|
+
* and clears it after.
|
|
19
|
+
*
|
|
20
|
+
* @param text - The previous segment's output, or null for none.
|
|
21
|
+
*/
|
|
22
|
+
export function stdin_set(text) {
|
|
23
|
+
piped = text;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Takes the piped text, once.
|
|
27
|
+
*
|
|
28
|
+
* @returns The text, or null when the builtin was not piped into.
|
|
29
|
+
*/
|
|
30
|
+
export function stdin_take() {
|
|
31
|
+
const text = piped;
|
|
32
|
+
piped = null;
|
|
33
|
+
return text;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The text a toy works on: what was piped in, else its arguments joined,
|
|
37
|
+
* else nothing.
|
|
38
|
+
*
|
|
39
|
+
* @param args - The builtin's arguments.
|
|
40
|
+
* @returns The text, or null when there is none either way.
|
|
41
|
+
*/
|
|
42
|
+
export function text_input(args) {
|
|
43
|
+
const fromPipe = stdin_take();
|
|
44
|
+
if (fromPipe !== null)
|
|
45
|
+
return fromPipe;
|
|
46
|
+
return args.length > 0 ? args.join(' ') : null;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=stdin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin.js","sourceRoot":"","sources":["../../../src/builtins/games/stdin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,6EAA6E;AAC7E,IAAI,KAAK,GAAkB,IAAI,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAmB;IAC3C,KAAK,GAAG,IAAI,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,GAAkB,KAAK,CAAC;IAClC,KAAK,GAAG,IAAI,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAA2B;IACpD,MAAM,QAAQ,GAAkB,UAAU,EAAE,CAAC;IAC7C,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IACvC,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Text toys from the shelf: `rev`, `tac`, `yes`, `seq`, `shuf`, `rot13`.
|
|
3
|
+
*
|
|
4
|
+
* Each reads what was piped in, else its arguments, and answers in kind:
|
|
5
|
+
* `fortune | rev`, `rot13 hello`, `seq 1 2 9`. `yes` is bounded — a shell
|
|
6
|
+
* that never ends is not a toy — and says how many it printed.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { CommandEnvelope } from '@fnndsc/cumin';
|
|
11
|
+
/** Lines `yes` prints when not told how many. */
|
|
12
|
+
export declare const YES_DEFAULT: number;
|
|
13
|
+
/** The most lines `yes` prints however it is asked. */
|
|
14
|
+
export declare const YES_MAX: number;
|
|
15
|
+
/** The most numbers `seq` prints. */
|
|
16
|
+
export declare const SEQ_MAX: number;
|
|
17
|
+
/** Reverses each line's characters, keeping the lines. */
|
|
18
|
+
export declare function text_rev(text: string): string;
|
|
19
|
+
/** Reverses the order of the lines. */
|
|
20
|
+
export declare function text_tac(text: string): string;
|
|
21
|
+
/** The ROT13 of a text; letters only, case kept. */
|
|
22
|
+
export declare function text_rot13(text: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* The numbers `seq` prints: `seq LAST`, `seq FIRST LAST`, `seq FIRST STEP LAST`.
|
|
25
|
+
*
|
|
26
|
+
* @returns The numbers, or a refusal.
|
|
27
|
+
*/
|
|
28
|
+
export declare function seq_numbers(args: ReadonlyArray<string>): {
|
|
29
|
+
numbers: number[];
|
|
30
|
+
} | {
|
|
31
|
+
refusal: string;
|
|
32
|
+
};
|
|
33
|
+
/** Shuffles lines (Fisher–Yates), with an optional source of chance for tests. */
|
|
34
|
+
export declare function lines_shuffle(lines: string[], random?: () => number): string[];
|
|
35
|
+
/** `rev [text]` */
|
|
36
|
+
export declare function builtin_rev(args: string[]): Promise<CommandEnvelope>;
|
|
37
|
+
/** `tac [text]` */
|
|
38
|
+
export declare function builtin_tac(args: string[]): Promise<CommandEnvelope>;
|
|
39
|
+
/** `yes [word] [-n N]` */
|
|
40
|
+
export declare function builtin_yes(args: string[]): Promise<CommandEnvelope>;
|
|
41
|
+
/** `seq [FIRST [STEP]] LAST` */
|
|
42
|
+
export declare function builtin_seq(args: string[]): Promise<CommandEnvelope>;
|
|
43
|
+
/** `shuf [words...]`: lines piped in, or the words given, in a random order. */
|
|
44
|
+
export declare function builtin_shuf(args: string[]): Promise<CommandEnvelope>;
|
|
45
|
+
/** `rot13 [text]` */
|
|
46
|
+
export declare function builtin_rot13(args: string[]): Promise<CommandEnvelope>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Text toys from the shelf: `rev`, `tac`, `yes`, `seq`, `shuf`, `rot13`.
|
|
3
|
+
*
|
|
4
|
+
* Each reads what was piped in, else its arguments, and answers in kind:
|
|
5
|
+
* `fortune | rev`, `rot13 hello`, `seq 1 2 9`. `yes` is bounded — a shell
|
|
6
|
+
* that never ends is not a toy — and says how many it printed.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { envelope_ok, envelope_error } from '@fnndsc/cumin';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { text_input } from './stdin.js';
|
|
13
|
+
/** Lines `yes` prints when not told how many. */
|
|
14
|
+
export const YES_DEFAULT = 10;
|
|
15
|
+
/** The most lines `yes` prints however it is asked. */
|
|
16
|
+
export const YES_MAX = 10_000;
|
|
17
|
+
/** The most numbers `seq` prints. */
|
|
18
|
+
export const SEQ_MAX = 100_000;
|
|
19
|
+
/** Reverses each line's characters, keeping the lines. */
|
|
20
|
+
export function text_rev(text) {
|
|
21
|
+
return text.split('\n').map((line) => [...line].reverse().join('')).join('\n');
|
|
22
|
+
}
|
|
23
|
+
/** Reverses the order of the lines. */
|
|
24
|
+
export function text_tac(text) {
|
|
25
|
+
const trailing = text.endsWith('\n');
|
|
26
|
+
const lines = (trailing ? text.slice(0, -1) : text).split('\n');
|
|
27
|
+
return lines.reverse().join('\n') + (trailing ? '\n' : '');
|
|
28
|
+
}
|
|
29
|
+
/** The ROT13 of a text; letters only, case kept. */
|
|
30
|
+
export function text_rot13(text) {
|
|
31
|
+
return text.replace(/[a-zA-Z]/g, (c) => {
|
|
32
|
+
const base = c <= 'Z' ? 65 : 97;
|
|
33
|
+
return String.fromCharCode(((c.charCodeAt(0) - base + 13) % 26) + base);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The numbers `seq` prints: `seq LAST`, `seq FIRST LAST`, `seq FIRST STEP LAST`.
|
|
38
|
+
*
|
|
39
|
+
* @returns The numbers, or a refusal.
|
|
40
|
+
*/
|
|
41
|
+
export function seq_numbers(args) {
|
|
42
|
+
const nums = args.map(Number);
|
|
43
|
+
if (nums.length === 0 || nums.length > 3 || nums.some((n) => !Number.isFinite(n))) {
|
|
44
|
+
return { refusal: 'seq: usage: seq [FIRST [STEP]] LAST' };
|
|
45
|
+
}
|
|
46
|
+
const [first, step, last] = nums.length === 1 ? [1, 1, nums[0]]
|
|
47
|
+
: nums.length === 2 ? [nums[0], 1, nums[1]]
|
|
48
|
+
: [nums[0], nums[1], nums[2]];
|
|
49
|
+
if (step === 0)
|
|
50
|
+
return { refusal: 'seq: STEP must not be zero' };
|
|
51
|
+
const numbers = [];
|
|
52
|
+
for (let n = first; step > 0 ? n <= last : n >= last; n += step) {
|
|
53
|
+
numbers.push(Number(n.toFixed(10)));
|
|
54
|
+
if (numbers.length >= SEQ_MAX)
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
return { numbers };
|
|
58
|
+
}
|
|
59
|
+
/** Shuffles lines (Fisher–Yates), with an optional source of chance for tests. */
|
|
60
|
+
export function lines_shuffle(lines, random = Math.random) {
|
|
61
|
+
const out = [...lines];
|
|
62
|
+
for (let i = out.length - 1; i > 0; i--) {
|
|
63
|
+
const j = Math.floor(random() * (i + 1));
|
|
64
|
+
[out[i], out[j]] = [out[j], out[i]];
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/** `rev [text]` */
|
|
69
|
+
export async function builtin_rev(args) {
|
|
70
|
+
const text = text_input(args);
|
|
71
|
+
if (text === null)
|
|
72
|
+
return envelope_error('', undefined, 'rev: nothing to reverse (pipe text in, or give it)\n');
|
|
73
|
+
const out = text_rev(text.replace(/\n$/, ''));
|
|
74
|
+
return envelope_ok(`${out}\n`, { kind: 'games.rev', data: { text: out } });
|
|
75
|
+
}
|
|
76
|
+
/** `tac [text]` */
|
|
77
|
+
export async function builtin_tac(args) {
|
|
78
|
+
const text = text_input(args);
|
|
79
|
+
if (text === null)
|
|
80
|
+
return envelope_error('', undefined, 'tac: nothing to turn over (pipe lines in)\n');
|
|
81
|
+
const out = text_tac(text.endsWith('\n') ? text : `${text}\n`);
|
|
82
|
+
return envelope_ok(out, { kind: 'games.tac', data: { text: out } });
|
|
83
|
+
}
|
|
84
|
+
/** `yes [word] [-n N]` */
|
|
85
|
+
export async function builtin_yes(args) {
|
|
86
|
+
let count = YES_DEFAULT;
|
|
87
|
+
const words = [];
|
|
88
|
+
for (let i = 0; i < args.length; i++) {
|
|
89
|
+
if (args[i] === '-n') {
|
|
90
|
+
const n = Number(args[i + 1]);
|
|
91
|
+
if (!Number.isInteger(n) || n < 1)
|
|
92
|
+
return envelope_error('', undefined, 'yes: -n wants a positive whole number\n');
|
|
93
|
+
count = Math.min(n, YES_MAX);
|
|
94
|
+
i++;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
words.push(args[i]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const word = words.length > 0 ? words.join(' ') : 'y';
|
|
101
|
+
const lines = `${word}\n`.repeat(count);
|
|
102
|
+
// Bounded on purpose, and it says so: the real yes runs until killed.
|
|
103
|
+
const note = chalk.gray(`yes: ${count} of forever (-n N for more, up to ${YES_MAX})\n`);
|
|
104
|
+
return envelope_ok(lines + note, { kind: 'games.yes', data: { word, count } });
|
|
105
|
+
}
|
|
106
|
+
/** `seq [FIRST [STEP]] LAST` */
|
|
107
|
+
export async function builtin_seq(args) {
|
|
108
|
+
const answer = seq_numbers(args);
|
|
109
|
+
if ('refusal' in answer)
|
|
110
|
+
return envelope_error('', undefined, `${answer.refusal}\n`);
|
|
111
|
+
const note = answer.numbers.length >= SEQ_MAX ? chalk.gray(`seq: stopped at ${SEQ_MAX} numbers\n`) : '';
|
|
112
|
+
return envelope_ok(`${answer.numbers.join('\n')}\n${note}`, { kind: 'games.seq', data: { numbers: answer.numbers } });
|
|
113
|
+
}
|
|
114
|
+
/** `shuf [words...]`: lines piped in, or the words given, in a random order. */
|
|
115
|
+
export async function builtin_shuf(args) {
|
|
116
|
+
const piped = text_input([]);
|
|
117
|
+
const lines = piped !== null
|
|
118
|
+
? piped.replace(/\n$/, '').split('\n')
|
|
119
|
+
: args;
|
|
120
|
+
if (lines.length === 0)
|
|
121
|
+
return envelope_error('', undefined, 'shuf: nothing to shuffle (pipe lines in, or give words)\n');
|
|
122
|
+
const out = lines_shuffle(lines);
|
|
123
|
+
return envelope_ok(`${out.join('\n')}\n`, { kind: 'games.shuf', data: { lines: out } });
|
|
124
|
+
}
|
|
125
|
+
/** `rot13 [text]` */
|
|
126
|
+
export async function builtin_rot13(args) {
|
|
127
|
+
const text = text_input(args);
|
|
128
|
+
if (text === null)
|
|
129
|
+
return envelope_error('', undefined, 'rot13: nothing to turn (pipe text in, or give it)\n');
|
|
130
|
+
const out = text_rot13(text.replace(/\n$/, ''));
|
|
131
|
+
return envelope_ok(`${out}\n`, { kind: 'games.rot13', data: { text: out } });
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/builtins/games/text.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,iDAAiD;AACjD,M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KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QACtC,CAAC,CAAC,IAAI,CAAC;IACT,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,2DAA2D,CAAC,CAAC;IAC1H,MAAM,GAAG,GAAa,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,WAAW,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAC1F,CAAC;AAED,qBAAqB;AACrB,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAc;IAChD,MAAM,IAAI,GAAkB,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,qDAAqD,CAAC,CAAC;IAC/G,MAAM,GAAG,GAAW,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACxD,OAAO,WAAW,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `wtf`: what an acronym means, from the book in `wtf.data.ts`.
|
|
3
|
+
*
|
|
4
|
+
* `wtf is lonk`, `wtf lonk`, `wtf cube pfdcm`. A term the book lacks is
|
|
5
|
+
* said so; `wtf -l` lists every term it has.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { CommandEnvelope } from '@fnndsc/cumin';
|
|
10
|
+
/** The meanings of a term, or none. */
|
|
11
|
+
export declare function wtf_lookup(term: string): ReadonlyArray<string>;
|
|
12
|
+
/** `wtf [is] <term>... | wtf -l` */
|
|
13
|
+
export declare function builtin_wtf(args: string[]): Promise<CommandEnvelope>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file What the acronyms around here mean: the book `wtf` reads from.
|
|
3
|
+
*
|
|
4
|
+
* BSD's `wtf` read /usr/share/misc/acronyms. Ours reads this: the ChRIS and
|
|
5
|
+
* DICOM words a new user meets in their first hour, and the names of the
|
|
6
|
+
* mise packages. Keys are matched without regard to case; a key may have
|
|
7
|
+
* several meanings, each its own line.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/** The book: a term to its meanings. */
|
|
12
|
+
export declare const ACRONYMS: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file What the acronyms around here mean: the book `wtf` reads from.
|
|
3
|
+
*
|
|
4
|
+
* BSD's `wtf` read /usr/share/misc/acronyms. Ours reads this: the ChRIS and
|
|
5
|
+
* DICOM words a new user meets in their first hour, and the names of the
|
|
6
|
+
* mise packages. Keys are matched without regard to case; a key may have
|
|
7
|
+
* several meanings, each its own line.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/** The book: a term to its meanings. */
|
|
12
|
+
export const ACRONYMS = {
|
|
13
|
+
chris: ['ChRIS — the ChRIS Research Integration System: a platform that runs containerised analyses (plugins) on medical data, by the FNNDSC at Boston Children\'s Hospital'],
|
|
14
|
+
cube: ['CUBE — the ChRIS Ultron Back End: the REST API and database every ChRIS surface talks to (a Django app)'],
|
|
15
|
+
fnndsc: ['FNNDSC — the Fetal-Neonatal Neuroimaging and Developmental Science Center, Boston Children\'s Hospital; ChRIS\'s home'],
|
|
16
|
+
feed: ['feed — one analysis in ChRIS: a tree of plugin instances rooted on some data; what ARGUS lists under ANALYSES'],
|
|
17
|
+
plugin: ['plugin — a containerised program ChRIS can run; a step in a feed. Kinds: fs (makes data from nothing), ds (data in, data out), ts (joins several parents)'],
|
|
18
|
+
pipeline: ['pipeline — a saved shape of plugins to run in order, with their parameters; what `pipeline run` starts and `/bin` lists'],
|
|
19
|
+
instance: ['plugin instance — one run of a plugin inside a feed, with its own parameters, status and output folder; a job'],
|
|
20
|
+
job: ['job — a plugin instance, as `proc` and the dashboard count them'],
|
|
21
|
+
cfs: ['CFS — the ChRIS filesystem: the files CUBE holds, under /home/<user>, /SERVICES/PACS, /PIPELINES, /SHARED and /PUBLIC'],
|
|
22
|
+
swift: ['Swift — the object store CUBE kept files in originally; the paths in CFS still look like it'],
|
|
23
|
+
pfcon: ['pfcon — the process-and-file controller: the service CUBE hands a plugin run to, which stages the data and starts the container'],
|
|
24
|
+
pman: ['pman — the process manager behind pfcon: starts containers on a compute (Docker, Swarm, Kubernetes, Slurm)'],
|
|
25
|
+
pfdcm: ['pfdcm — the PACS front end: the service that asks a PACS (C-FIND) and tells it to send (C-MOVE); `pacs query` and `pull` go through it'],
|
|
26
|
+
oxidicom: ['oxidicom — the DICOM receiver (in Rust) that the PACS sends files to; it stores them and registers them in CUBE, and reports progress over LONK'],
|
|
27
|
+
lonk: ['LONK — Light Oxidicom NotifiKations: the small messages oxidicom publishes (over NATS) as a series arrives: a file count, done, or an error'],
|
|
28
|
+
nats: ['NATS — the message bus oxidicom publishes LONK on; CUBE relays it to a websocket a pull watches'],
|
|
29
|
+
pacs: ['PACS — Picture Archiving and Communication System: the hospital\'s image archive, spoken to in DICOM'],
|
|
30
|
+
dicom: ['DICOM — Digital Imaging and Communications in Medicine: the file format and the network protocol of medical imaging'],
|
|
31
|
+
'c-find': ['C-FIND — the DICOM query: ask a PACS what it holds (`pacs query`)'],
|
|
32
|
+
'c-move': ['C-MOVE — the DICOM retrieve: tell a PACS to send a study or series to a receiver (`pull`, with oxidicom receiving)'],
|
|
33
|
+
'c-store': ['C-STORE — the DICOM send: one image delivered to a receiver; what a C-MOVE sets off, many times'],
|
|
34
|
+
ae: ['AE title — Application Entity title: the name a DICOM node goes by on the network (the receiver here is an AE title the PACS knows)'],
|
|
35
|
+
aetitle: ['AE title — Application Entity title: the name a DICOM node goes by on the network'],
|
|
36
|
+
mrn: ['MRN — Medical Record Number: the hospital\'s patient identifier; PatientID in DICOM'],
|
|
37
|
+
accession: ['accession number — the identifier of one imaging order/study at the hospital; AccessionNumber in DICOM'],
|
|
38
|
+
study: ['study — one imaging visit in DICOM, holding series'],
|
|
39
|
+
series: ['series — one acquisition in a study: a stack of images of one kind (an axial T1, say); what `pull` fetches'],
|
|
40
|
+
sop: ['SOP — Service-Object Pair: DICOM\'s name for a kind of object (an MR image) and the services on it; a SOPInstanceUID names one image'],
|
|
41
|
+
uid: ['UID — a DICOM unique identifier (dotted numbers): StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID'],
|
|
42
|
+
modality: ['modality — the kind of scanner: MR, CT, US, CR, DX, PT …'],
|
|
43
|
+
mpr: ['MPR — multiplanar reconstruction: a volume resliced into other planes'],
|
|
44
|
+
sr: ['SR — Structured Report: a DICOM document rather than an image (a radiology report); a PACS will often not send these'],
|
|
45
|
+
hu: ['HU — Hounsfield unit: CT intensity, water at 0, air at −1000'],
|
|
46
|
+
nifti: ['NIfTI — the neuroimaging volume format (.nii, .nii.gz) most analysis tools read; what DICOM gets converted to'],
|
|
47
|
+
bids: ['BIDS — the Brain Imaging Data Structure: a folder and naming convention for neuroimaging datasets'],
|
|
48
|
+
freesurfer: ['FreeSurfer — the brain MRI analysis suite (cortical surfaces, segmentations) many ChRIS plugins wrap'],
|
|
49
|
+
seagap: ['SeaGaP — Search, Gather, Process: the ChRIS workflow ARGUS is built around — find data, gather a cohort, run a pipeline on it'],
|
|
50
|
+
cohort: ['cohort — the set of series or files gathered to process together; GATHER in ARGUS; kept in ~/gather'],
|
|
51
|
+
mise: ['mise — this framework: an intent kernel (brasa) with surfaces (chell, ARGUS); the name is "mise en place"'],
|
|
52
|
+
brasa: ['brasa — the intent kernel: every command\'s meaning, returning typed envelopes; knows no surface'],
|
|
53
|
+
chell: ['chell — the terminal surface: a shell over brasa; also the program that starts a daemon'],
|
|
54
|
+
calypso: ['CALYPSO — the daemon: one session many surfaces attach to over a websocket; Accepts Language, Yielding Permitted Shell Operations'],
|
|
55
|
+
argus: ['ARGUS — the browser surface: panes over the same session, drawn in LCARS'],
|
|
56
|
+
porter: ['porter — the display manager: the door (login) that starts or finds a user\'s daemon and serves ARGUS behind it'],
|
|
57
|
+
menu: ['menu — the wire package: the message and model schemas every surface and the daemon agree on'],
|
|
58
|
+
cumin: ['cumin — the base library: the CUBE client, connection, caches and the error stack'],
|
|
59
|
+
salsa: ['salsa — the data layer: files, feeds, the virtual filesystem providers, the retrieve watch'],
|
|
60
|
+
chili: ['chili — the older command layer: the path mapper and the commands brasa still delegates to'],
|
|
61
|
+
orrery: ['orrery — the scene package: molecules, galaxies and the universe, drawn for ARGUS'],
|
|
62
|
+
envelope: ['envelope — what a command returns: rendered text, a status, and a typed model a surface may draw'],
|
|
63
|
+
lcars: ['LCARS — Library Computer Access/Retrieval System: the Star Trek interface ARGUS\'s look is after'],
|
|
64
|
+
aegis: ['AEGIS — ARGUS\'s interface standard: the laws every pane obeys, in apps/argus/docs/aegis.adoc'],
|
|
65
|
+
harbor: ['HARBOR — the project board the mise epics are tracked on'],
|
|
66
|
+
k8s: ['k8s — Kubernetes, which runs CUBE and its services here'],
|
|
67
|
+
oidc: ['OIDC — OpenID Connect; how the mise packages publish to npm without a token'],
|
|
68
|
+
wtf: ['wtf — this: BSD\'s acronym expander, with this book instead of /usr/share/misc/acronyms'],
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=wtf.data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wtf.data.js","sourceRoot":"","sources":["../../../src/builtins/games/wtf.data.ts"],"names":[],"mappings":"AAAA;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