bivium 0.9.0 → 0.10.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/README.md +10 -6
- package/cli.js +51 -2192
- package/compute.js +4 -3
- package/config.js +3 -2
- package/docs/api.md +1 -0
- package/docs/ci.md +21 -0
- package/docs/cli.md +28 -2
- package/docs/config.md +50 -0
- package/docs/how-it-works.md +99 -0
- package/docs/tuning.md +24 -1
- package/errors.js +2 -1
- package/index.d.ts +6 -0
- package/package.json +1 -1
- package/shared-118ck8qt.js +40 -0
- package/{shared-07rt4zr7.js → shared-70w84x4c.js} +2007 -1350
- package/shared-84c9vs8a.js +475 -0
- package/shared-a5kfg3qy.js +68 -0
- package/shared-a8ebfhzf.js +319 -0
- package/shared-byhfswm9.js +1047 -0
- package/shared-graedbt1.js +12 -0
- package/shared-ke52sg37.js +149 -0
- package/shared-m8z858pr.js +26 -0
- package/shared-my87dhfd.js +164 -0
- package/{shared-550cvwt2.js → shared-px5a17nj.js} +1 -1
- package/shared-qe34axez.js +19 -0
- package/shared-rzbfbyqq.js +549 -0
- package/shared-v5gfq9zy.js +13 -0
- package/shared-wahjx628.js +66 -0
- package/shared-x17wzptz.js +4 -0
- package/shared-y7y281x3.js +103 -0
- package/shared-yfvpkeff.js +30 -0
- package/shared-211m8fjt.js +0 -69
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// src/terminal.ts
|
|
2
|
+
var asIs = (text) => text;
|
|
3
|
+
var PLAIN2 = {
|
|
4
|
+
good: asIs,
|
|
5
|
+
warn: asIs,
|
|
6
|
+
bad: asIs,
|
|
7
|
+
dim: asIs,
|
|
8
|
+
bold: asIs,
|
|
9
|
+
faint: asIs
|
|
10
|
+
};
|
|
11
|
+
function createPaint2() {
|
|
12
|
+
const wrap = (code) => (text) => text === "" ? text : `\x1B[${code}m${text}\x1B[39m`;
|
|
13
|
+
return {
|
|
14
|
+
good: wrap(32),
|
|
15
|
+
warn: wrap(33),
|
|
16
|
+
bad: wrap(31),
|
|
17
|
+
dim: wrap(90),
|
|
18
|
+
bold: (text) => text === "" ? text : `\x1B[1m${text}\x1B[22m`,
|
|
19
|
+
faint: (text) => text === "" ? text : `\x1B[2m${text}\x1B[22m`
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function wantsColor2(forced, terminal, env, agent) {
|
|
23
|
+
if (forced !== undefined)
|
|
24
|
+
return forced;
|
|
25
|
+
if ((env.NO_COLOR ?? "") !== "")
|
|
26
|
+
return false;
|
|
27
|
+
const force = env.FORCE_COLOR;
|
|
28
|
+
if (force !== undefined && force !== "")
|
|
29
|
+
return force !== "0";
|
|
30
|
+
return terminal && !agent && !isDumb2(env);
|
|
31
|
+
}
|
|
32
|
+
var isDumb2 = (env) => env.TERM === "dumb";
|
|
33
|
+
var AGENT_ENV = [
|
|
34
|
+
"AGENT",
|
|
35
|
+
"AI_AGENT",
|
|
36
|
+
"CLAUDECODE",
|
|
37
|
+
"CODEX_CI",
|
|
38
|
+
"CODEX_THREAD_ID"
|
|
39
|
+
];
|
|
40
|
+
var agentVariableOf = (env) => AGENT_ENV.find((name) => {
|
|
41
|
+
const value = env[name];
|
|
42
|
+
return value !== undefined && value !== "" && value !== "0";
|
|
43
|
+
});
|
|
44
|
+
var isAgent2 = (env) => agentVariableOf(env) !== undefined;
|
|
45
|
+
var UNICODE_GLYPHS2 = {
|
|
46
|
+
done: "✓",
|
|
47
|
+
failed: "✗",
|
|
48
|
+
skipped: "-",
|
|
49
|
+
pending: "○",
|
|
50
|
+
spinner: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
|
|
51
|
+
pointer: "›",
|
|
52
|
+
picked: "●",
|
|
53
|
+
unpicked: "○",
|
|
54
|
+
up: "↑",
|
|
55
|
+
down: "↓",
|
|
56
|
+
upDown: "↑↓",
|
|
57
|
+
leftRight: "←→",
|
|
58
|
+
barDone: "━",
|
|
59
|
+
barTodo: "─"
|
|
60
|
+
};
|
|
61
|
+
var ASCII_GLYPHS2 = {
|
|
62
|
+
done: "+",
|
|
63
|
+
failed: "x",
|
|
64
|
+
skipped: "-",
|
|
65
|
+
pending: ".",
|
|
66
|
+
spinner: [">"],
|
|
67
|
+
pointer: ">",
|
|
68
|
+
picked: "[x]",
|
|
69
|
+
unpicked: "[ ]",
|
|
70
|
+
up: "^",
|
|
71
|
+
down: "v",
|
|
72
|
+
upDown: "up/down",
|
|
73
|
+
leftRight: "left/right",
|
|
74
|
+
barDone: "=",
|
|
75
|
+
barTodo: "-"
|
|
76
|
+
};
|
|
77
|
+
var markOf2 = (glyphs, mark) => glyphs[mark] ?? UNICODE_GLYPHS2[mark];
|
|
78
|
+
function wantsAscii2(env) {
|
|
79
|
+
if (isDumb2(env))
|
|
80
|
+
return true;
|
|
81
|
+
const locale = env.LC_ALL || env.LC_CTYPE || env.LANG;
|
|
82
|
+
return locale !== undefined && locale !== "" && !/utf-?8/i.test(locale);
|
|
83
|
+
}
|
|
84
|
+
var HIDE_CURSOR = "\x1B[?25l";
|
|
85
|
+
var SHOW_CURSOR = "\x1B[?25h";
|
|
86
|
+
var cursor = { hidden: false };
|
|
87
|
+
function hideCursor2() {
|
|
88
|
+
cursor.hidden = true;
|
|
89
|
+
return HIDE_CURSOR;
|
|
90
|
+
}
|
|
91
|
+
function showCursor2() {
|
|
92
|
+
cursor.hidden = false;
|
|
93
|
+
return SHOW_CURSOR;
|
|
94
|
+
}
|
|
95
|
+
var cursorHidden2 = () => cursor.hidden;
|
|
96
|
+
var SEPARATOR2 = " · ";
|
|
97
|
+
var branch2 = (index, count) => index === count - 1 ? "└ " : "├ ";
|
|
98
|
+
var NOTE_INDENT2 = " ";
|
|
99
|
+
function closingLine2(paint, what, detail, glyphs = UNICODE_GLYPHS2) {
|
|
100
|
+
return `${paint.good(glyphs.done)} ${what}${detail === undefined ? "" : paint.dim(`${SEPARATOR2}${detail}`)}`;
|
|
101
|
+
}
|
|
102
|
+
function failLine2(paint, what, detail, glyphs = UNICODE_GLYPHS2) {
|
|
103
|
+
return `${paint.bad(glyphs.failed)} ${what}${detail === undefined ? "" : paint.dim(`${SEPARATOR2}${detail}`)}`;
|
|
104
|
+
}
|
|
105
|
+
var keyHints2 = (paint, keys) => paint.faint(keys.map((k) => `${k.key} ${k.does}`).join(SEPARATOR2));
|
|
106
|
+
function distance(a, b) {
|
|
107
|
+
const width = b.length + 1;
|
|
108
|
+
const cells = new Uint32Array((a.length + 1) * width);
|
|
109
|
+
const d = (i, j) => cells[i * width + j] ?? 0;
|
|
110
|
+
for (let i = 0;i <= a.length; i++)
|
|
111
|
+
cells[i * width] = i;
|
|
112
|
+
for (let j = 0;j <= b.length; j++)
|
|
113
|
+
cells[j] = j;
|
|
114
|
+
for (let i = 1;i <= a.length; i++) {
|
|
115
|
+
for (let j = 1;j <= b.length; j++) {
|
|
116
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
117
|
+
let best = Math.min(d(i - 1, j) + 1, d(i, j - 1) + 1, d(i - 1, j - 1) + cost);
|
|
118
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
119
|
+
best = Math.min(best, d(i - 2, j - 2) + 1);
|
|
120
|
+
}
|
|
121
|
+
cells[i * width + j] = best;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return d(a.length, b.length);
|
|
125
|
+
}
|
|
126
|
+
function shareLetter(a, b) {
|
|
127
|
+
const letters = new Set(a.replace(/^-+/, "").toLowerCase());
|
|
128
|
+
for (const c of b.replace(/^-+/, "").toLowerCase()) {
|
|
129
|
+
if (letters.has(c))
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
function nearest2(input, candidates) {
|
|
135
|
+
const most = Math.max(1, Math.floor(input.length / 3));
|
|
136
|
+
let best;
|
|
137
|
+
let bestDistance = most + 1;
|
|
138
|
+
for (const candidate of candidates) {
|
|
139
|
+
const d = distance(input, candidate);
|
|
140
|
+
if (d < bestDistance && shareLetter(input, candidate)) {
|
|
141
|
+
best = candidate;
|
|
142
|
+
bestDistance = d;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return best;
|
|
146
|
+
}
|
|
147
|
+
function truncateWords2(text, max) {
|
|
148
|
+
if ([...text].length <= max)
|
|
149
|
+
return text;
|
|
150
|
+
const cut = [...text].slice(0, max - 1).join("");
|
|
151
|
+
const space = cut.lastIndexOf(" ");
|
|
152
|
+
return `${(space > max / 2 ? cut.slice(0, space) : cut).replace(/[\s,;:]+$/, "")}…`;
|
|
153
|
+
}
|
|
154
|
+
var HASH_TAIL = /[-.][^-./]+\.\w+$/;
|
|
155
|
+
var WORD_END = /(?<=[-_.])/;
|
|
156
|
+
var width = (text) => [...text].length;
|
|
157
|
+
function truncatePath2(path, max) {
|
|
158
|
+
if (width(path) <= max)
|
|
159
|
+
return path;
|
|
160
|
+
const parts = path.split("/");
|
|
161
|
+
const name = parts.pop() ?? path;
|
|
162
|
+
for (let keep = parts.length - 1;keep >= 0; keep--) {
|
|
163
|
+
const candidate = `…/${[...parts.slice(parts.length - keep), name].join("/")}`;
|
|
164
|
+
if (width(candidate) <= max)
|
|
165
|
+
return candidate;
|
|
166
|
+
}
|
|
167
|
+
const prefix = parts.length > 0 ? "…/" : "";
|
|
168
|
+
const tail = HASH_TAIL.exec(name)?.[0] ?? "";
|
|
169
|
+
const stem = name.slice(0, name.length - tail.length);
|
|
170
|
+
const room = max - width(prefix) - width(tail) - 1;
|
|
171
|
+
if (room < 4)
|
|
172
|
+
return `${prefix}…${[...name].slice(-(max - width(prefix) - 1)).join("")}`;
|
|
173
|
+
const words = stem.split(WORD_END);
|
|
174
|
+
const first = words[0] ?? "";
|
|
175
|
+
let end = "";
|
|
176
|
+
for (let i = words.length - 1;i > 0; i--) {
|
|
177
|
+
const word = words[i] ?? "";
|
|
178
|
+
if (width(first) + 1 + width(word + end) > room)
|
|
179
|
+
break;
|
|
180
|
+
end = word + end;
|
|
181
|
+
}
|
|
182
|
+
return end === "" ? `${prefix}${[...stem].slice(0, room).join("")}…${tail}` : `${prefix}${first}…${end}${tail}`;
|
|
183
|
+
}
|
|
184
|
+
var ESCAPE = /\x1b\[[0-9;]*m/g;
|
|
185
|
+
var LEADING_ESCAPE = /^\x1b\[[0-9;]*m/;
|
|
186
|
+
var textWidth2 = (text) => typeof Bun === "undefined" ? [...text.replace(ESCAPE, "")].length : Bun.stringWidth(text);
|
|
187
|
+
var MEASURE2 = 80;
|
|
188
|
+
function hangOf(line) {
|
|
189
|
+
const plain = line.replace(ESCAPE, "");
|
|
190
|
+
const lead = /^ */.exec(plain)?.[0].length ?? 0;
|
|
191
|
+
const gap = /^ *\S.*? {2,}(?=\S)/.exec(plain);
|
|
192
|
+
return gap ? textWidth2(gap[0]) : lead;
|
|
193
|
+
}
|
|
194
|
+
function splitAt(line, columns) {
|
|
195
|
+
let seen = 0;
|
|
196
|
+
let i = 0;
|
|
197
|
+
while (i < line.length && seen < columns) {
|
|
198
|
+
const escape = LEADING_ESCAPE.exec(line.slice(i));
|
|
199
|
+
if (escape) {
|
|
200
|
+
i += escape[0].length;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const ch = String.fromCodePoint(line.codePointAt(i) ?? 32);
|
|
204
|
+
seen += textWidth2(ch);
|
|
205
|
+
i += ch.length;
|
|
206
|
+
}
|
|
207
|
+
return [line.slice(0, i), line.slice(i)];
|
|
208
|
+
}
|
|
209
|
+
var fitTerminal2 = (text, terminal, columns) => terminal ? fitWidth2(text, Math.min(MEASURE2, columns || MEASURE2)) : text;
|
|
210
|
+
function wordsOf(text) {
|
|
211
|
+
const words = [];
|
|
212
|
+
for (const word of text.split(/ +/)) {
|
|
213
|
+
const last = words.at(-1);
|
|
214
|
+
if (last !== undefined && last.replace(ESCAPE, "") === "·") {
|
|
215
|
+
words[words.length - 1] = `${last} ${word}`;
|
|
216
|
+
} else if (word !== "")
|
|
217
|
+
words.push(word);
|
|
218
|
+
}
|
|
219
|
+
return words;
|
|
220
|
+
}
|
|
221
|
+
function wrapWords(words, room, breakWords) {
|
|
222
|
+
const lines = [];
|
|
223
|
+
let current = "";
|
|
224
|
+
for (const word of words) {
|
|
225
|
+
const pieces = [];
|
|
226
|
+
let rest = word;
|
|
227
|
+
while (breakWords && textWidth2(rest) > room) {
|
|
228
|
+
const [piece, after] = splitAt(rest, room);
|
|
229
|
+
pieces.push(piece);
|
|
230
|
+
rest = after;
|
|
231
|
+
}
|
|
232
|
+
pieces.push(rest);
|
|
233
|
+
for (const piece of pieces) {
|
|
234
|
+
const next = current === "" ? piece : `${current} ${piece}`;
|
|
235
|
+
if (current !== "" && textWidth2(next) > room) {
|
|
236
|
+
lines.push(current);
|
|
237
|
+
current = piece;
|
|
238
|
+
} else {
|
|
239
|
+
current = next;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (current !== "")
|
|
244
|
+
lines.push(current);
|
|
245
|
+
return lines;
|
|
246
|
+
}
|
|
247
|
+
function fitWidth2(text, width) {
|
|
248
|
+
return text.split(`
|
|
249
|
+
`).flatMap((line) => {
|
|
250
|
+
if (textWidth2(line) <= width)
|
|
251
|
+
return [line];
|
|
252
|
+
let hang = hangOf(line);
|
|
253
|
+
if (hang > width / 2)
|
|
254
|
+
hang = /^ */.exec(line.replace(ESCAPE, ""))?.[0].length ?? 0;
|
|
255
|
+
const [head, rest] = splitAt(line, hang);
|
|
256
|
+
const room = Math.max(1, width - hang);
|
|
257
|
+
return wrapWords(wordsOf(rest), room, false).map((part, k) => (k === 0 ? head : " ".repeat(hang)) + part);
|
|
258
|
+
}).join(`
|
|
259
|
+
`);
|
|
260
|
+
}
|
|
261
|
+
var RULE2 = "\x00rule";
|
|
262
|
+
function aligned2(table, rightColumns = [], paintRule = asIs, indent = " ") {
|
|
263
|
+
const blank = (cell) => cell === "" || cell === RULE2;
|
|
264
|
+
const used = new Set(table.flatMap((row) => row.flatMap((cell, i) => blank(cell) ? [] : [i])));
|
|
265
|
+
const keep = (row) => row.filter((_, i) => used.has(i));
|
|
266
|
+
const rows = table.map(keep);
|
|
267
|
+
const right = [...used].sort((a, b) => a - b).flatMap((column, i) => rightColumns.includes(column) ? [i] : []);
|
|
268
|
+
const cellWidth = (cell) => cell === RULE2 ? 0 : textWidth2(cell);
|
|
269
|
+
const widths = [];
|
|
270
|
+
for (const row of rows) {
|
|
271
|
+
for (const [i, cell] of row.entries()) {
|
|
272
|
+
if (i === row.length - 1 && !right.includes(i))
|
|
273
|
+
continue;
|
|
274
|
+
widths[i] = Math.max(widths[i] ?? 0, cellWidth(cell));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const pad = (cell, i) => " ".repeat(Math.max(0, (widths[i] ?? 0) - cellWidth(cell)));
|
|
278
|
+
const columnsWidth = (from, to) => widths.slice(from, to).reduce((sum, w) => sum + w + 2, 0);
|
|
279
|
+
return rows.map((row) => {
|
|
280
|
+
const first = row.indexOf(RULE2);
|
|
281
|
+
if (first !== -1) {
|
|
282
|
+
const last = row.lastIndexOf(RULE2);
|
|
283
|
+
const line = "─".repeat(columnsWidth(first, last + 1) - 2);
|
|
284
|
+
return `${indent}${" ".repeat(columnsWidth(0, first))}${paintRule(line)}`;
|
|
285
|
+
}
|
|
286
|
+
return `${indent}${row.map((cell, i) => right.includes(i) ? pad(cell, i) + cell : i === row.length - 1 ? cell : cell + pad(cell, i)).join(" ")}`.trimEnd();
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
var headerRow2 = (paint, cells) => cells.map((cell) => paint.faint(cell));
|
|
290
|
+
var plural2 = (count, one, many = `${one}s`) => `${count} ${count === 1 ? one : many}`;
|
|
291
|
+
var SILENT2 = { step: () => {}, clear: () => {} };
|
|
292
|
+
var BAR_WIDTH = 20;
|
|
293
|
+
var CLEAR_LINE = "\r\x1B[2K";
|
|
294
|
+
function createProgress2(write, paint, nowMs, glyphs = UNICODE_GLYPHS2) {
|
|
295
|
+
const startMs = nowMs();
|
|
296
|
+
let text = "";
|
|
297
|
+
let doneRatio = 0;
|
|
298
|
+
const render = () => {
|
|
299
|
+
const done = Math.round(Math.min(1, Math.max(0, doneRatio)) * BAR_WIDTH);
|
|
300
|
+
const bar = paint.good(markOf2(glyphs, "barDone").repeat(done)) + paint.dim(markOf2(glyphs, "barTodo").repeat(BAR_WIDTH - done));
|
|
301
|
+
const seconds = Math.floor((nowMs() - startMs) / 1000);
|
|
302
|
+
write(`${CLEAR_LINE}${bar} ${text}${paint.dim(` · ${seconds} s`)}`);
|
|
303
|
+
};
|
|
304
|
+
const timer = setInterval(render, 1000);
|
|
305
|
+
timer.unref();
|
|
306
|
+
return {
|
|
307
|
+
step(next, ratio) {
|
|
308
|
+
text = next;
|
|
309
|
+
doneRatio = ratio;
|
|
310
|
+
render();
|
|
311
|
+
},
|
|
312
|
+
clear() {
|
|
313
|
+
clearInterval(timer);
|
|
314
|
+
write(CLEAR_LINE);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export { PLAIN2, createPaint2, wantsColor2, isDumb2, isAgent2, UNICODE_GLYPHS2, ASCII_GLYPHS2, markOf2, wantsAscii2, hideCursor2, showCursor2, cursorHidden2, SEPARATOR2, branch2, NOTE_INDENT2, closingLine2, failLine2, keyHints2, nearest2, truncateWords2, truncatePath2, textWidth2, MEASURE2, fitTerminal2, fitWidth2, RULE2, aligned2, headerRow2, plural2, SILENT2, createProgress2 };
|