open-agents-ai 0.103.5 → 0.103.6
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/index.js +216 -54
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30007,6 +30007,152 @@ var init_setup = __esm({
|
|
|
30007
30007
|
}
|
|
30008
30008
|
});
|
|
30009
30009
|
|
|
30010
|
+
// packages/cli/dist/tui/tui-select.js
|
|
30011
|
+
function ansi3(code, text) {
|
|
30012
|
+
return isTTY3 ? `\x1B[${code}m${text}\x1B[0m` : text;
|
|
30013
|
+
}
|
|
30014
|
+
function fg2562(code, text) {
|
|
30015
|
+
return isTTY3 ? `\x1B[38;5;${code}m${text}\x1B[0m` : text;
|
|
30016
|
+
}
|
|
30017
|
+
function defaultRenderRow(item, focused, isActive) {
|
|
30018
|
+
const marker = isActive ? selectColors.green("\u25CF") : focused ? selectColors.orange("\u25CF") : selectColors.dim("\u25CB");
|
|
30019
|
+
const label = focused ? selectColors.orange(selectColors.bold(item.label)) : isActive ? selectColors.green(item.label) : item.label;
|
|
30020
|
+
const detail = item.detail ? ` ${selectColors.dim(item.detail)}` : "";
|
|
30021
|
+
return ` ${marker} ${label}${detail}`;
|
|
30022
|
+
}
|
|
30023
|
+
function tuiSelect(opts) {
|
|
30024
|
+
const { items, title, rl } = opts;
|
|
30025
|
+
const renderRow = opts.renderRow ?? defaultRenderRow;
|
|
30026
|
+
const activeKey = opts.activeKey ?? null;
|
|
30027
|
+
if (items.length === 0) {
|
|
30028
|
+
return Promise.resolve({ confirmed: false, key: null, index: -1 });
|
|
30029
|
+
}
|
|
30030
|
+
let cursor = activeKey ? items.findIndex((i) => i.key === activeKey) : 0;
|
|
30031
|
+
if (cursor < 0)
|
|
30032
|
+
cursor = 0;
|
|
30033
|
+
const termRows = process.stdout.rows ?? 24;
|
|
30034
|
+
const maxVisible = opts.maxVisible ?? Math.max(5, termRows - 6);
|
|
30035
|
+
let scrollOffset = Math.max(0, cursor - Math.floor(maxVisible / 2));
|
|
30036
|
+
let lastRenderedLines = 0;
|
|
30037
|
+
return new Promise((resolve31) => {
|
|
30038
|
+
const stdin = process.stdin;
|
|
30039
|
+
const hadRawMode = stdin.isRaw;
|
|
30040
|
+
if (rl) {
|
|
30041
|
+
rl.pause();
|
|
30042
|
+
}
|
|
30043
|
+
if (typeof stdin.setRawMode === "function") {
|
|
30044
|
+
stdin.setRawMode(true);
|
|
30045
|
+
}
|
|
30046
|
+
stdin.resume();
|
|
30047
|
+
process.stdout.write("\x1B[?25l");
|
|
30048
|
+
function clampScroll() {
|
|
30049
|
+
if (cursor < scrollOffset) {
|
|
30050
|
+
scrollOffset = cursor;
|
|
30051
|
+
} else if (cursor >= scrollOffset + maxVisible) {
|
|
30052
|
+
scrollOffset = cursor - maxVisible + 1;
|
|
30053
|
+
}
|
|
30054
|
+
scrollOffset = Math.max(0, Math.min(items.length - maxVisible, scrollOffset));
|
|
30055
|
+
if (scrollOffset < 0)
|
|
30056
|
+
scrollOffset = 0;
|
|
30057
|
+
}
|
|
30058
|
+
function render() {
|
|
30059
|
+
if (lastRenderedLines > 0) {
|
|
30060
|
+
process.stdout.write(`\x1B[${lastRenderedLines}A`);
|
|
30061
|
+
for (let i = 0; i < lastRenderedLines; i++) {
|
|
30062
|
+
process.stdout.write("\x1B[2K\n");
|
|
30063
|
+
}
|
|
30064
|
+
process.stdout.write(`\x1B[${lastRenderedLines}A`);
|
|
30065
|
+
}
|
|
30066
|
+
clampScroll();
|
|
30067
|
+
const lines = [];
|
|
30068
|
+
if (title) {
|
|
30069
|
+
lines.push(`
|
|
30070
|
+
${selectColors.bold(title)}`);
|
|
30071
|
+
lines.push("");
|
|
30072
|
+
}
|
|
30073
|
+
if (scrollOffset > 0) {
|
|
30074
|
+
lines.push(` ${selectColors.dim(` \u25B2 ${scrollOffset} more`)}`);
|
|
30075
|
+
}
|
|
30076
|
+
const visibleEnd = Math.min(items.length, scrollOffset + maxVisible);
|
|
30077
|
+
for (let i = scrollOffset; i < visibleEnd; i++) {
|
|
30078
|
+
const item = items[i];
|
|
30079
|
+
const focused = i === cursor;
|
|
30080
|
+
const isActive = item.key === activeKey;
|
|
30081
|
+
lines.push(renderRow(item, focused, isActive));
|
|
30082
|
+
}
|
|
30083
|
+
const remaining = items.length - visibleEnd;
|
|
30084
|
+
if (remaining > 0) {
|
|
30085
|
+
lines.push(` ${selectColors.dim(` \u25BC ${remaining} more`)}`);
|
|
30086
|
+
}
|
|
30087
|
+
lines.push("");
|
|
30088
|
+
lines.push(` ${selectColors.dim("\u2191/\u2193 navigate Enter select Esc cancel")}`);
|
|
30089
|
+
lines.push("");
|
|
30090
|
+
const output = lines.join("\n");
|
|
30091
|
+
process.stdout.write(output);
|
|
30092
|
+
lastRenderedLines = lines.length;
|
|
30093
|
+
}
|
|
30094
|
+
function cleanup() {
|
|
30095
|
+
stdin.removeListener("data", onData);
|
|
30096
|
+
process.stdout.write("\x1B[?25h");
|
|
30097
|
+
if (lastRenderedLines > 0) {
|
|
30098
|
+
process.stdout.write(`\x1B[${lastRenderedLines}A`);
|
|
30099
|
+
for (let i = 0; i < lastRenderedLines; i++) {
|
|
30100
|
+
process.stdout.write("\x1B[2K\n");
|
|
30101
|
+
}
|
|
30102
|
+
process.stdout.write(`\x1B[${lastRenderedLines}A`);
|
|
30103
|
+
}
|
|
30104
|
+
if (typeof stdin.setRawMode === "function") {
|
|
30105
|
+
stdin.setRawMode(hadRawMode ?? false);
|
|
30106
|
+
}
|
|
30107
|
+
if (rl) {
|
|
30108
|
+
rl.resume();
|
|
30109
|
+
rl.prompt(false);
|
|
30110
|
+
}
|
|
30111
|
+
}
|
|
30112
|
+
function onData(chunk) {
|
|
30113
|
+
const seq = chunk.toString("utf8");
|
|
30114
|
+
if (seq === "\x1B[A" || seq === "k") {
|
|
30115
|
+
cursor = Math.max(0, cursor - 1);
|
|
30116
|
+
render();
|
|
30117
|
+
} else if (seq === "\x1B[B" || seq === "j") {
|
|
30118
|
+
cursor = Math.min(items.length - 1, cursor + 1);
|
|
30119
|
+
render();
|
|
30120
|
+
} else if (seq === "\x1B[H" || seq === "g") {
|
|
30121
|
+
cursor = 0;
|
|
30122
|
+
render();
|
|
30123
|
+
} else if (seq === "\x1B[F" || seq === "G") {
|
|
30124
|
+
cursor = items.length - 1;
|
|
30125
|
+
render();
|
|
30126
|
+
} else if (seq === "\r" || seq === "\n") {
|
|
30127
|
+
cleanup();
|
|
30128
|
+
resolve31({ confirmed: true, key: items[cursor].key, index: cursor });
|
|
30129
|
+
} else if (seq === "\x1B" || seq === "\x1B\x1B" || seq === "q") {
|
|
30130
|
+
cleanup();
|
|
30131
|
+
resolve31({ confirmed: false, key: null, index: cursor });
|
|
30132
|
+
} else if (seq === "") {
|
|
30133
|
+
cleanup();
|
|
30134
|
+
resolve31({ confirmed: false, key: null, index: cursor });
|
|
30135
|
+
}
|
|
30136
|
+
}
|
|
30137
|
+
stdin.on("data", onData);
|
|
30138
|
+
render();
|
|
30139
|
+
});
|
|
30140
|
+
}
|
|
30141
|
+
var isTTY3, selectColors;
|
|
30142
|
+
var init_tui_select = __esm({
|
|
30143
|
+
"packages/cli/dist/tui/tui-select.js"() {
|
|
30144
|
+
"use strict";
|
|
30145
|
+
isTTY3 = process.stdout.isTTY ?? false;
|
|
30146
|
+
selectColors = {
|
|
30147
|
+
orange: (t) => fg2562(208, t),
|
|
30148
|
+
green: (t) => ansi3("32", t),
|
|
30149
|
+
dim: (t) => ansi3("2", t),
|
|
30150
|
+
bold: (t) => ansi3("1", t),
|
|
30151
|
+
cyan: (t) => ansi3("36", t)
|
|
30152
|
+
};
|
|
30153
|
+
}
|
|
30154
|
+
});
|
|
30155
|
+
|
|
30010
30156
|
// packages/cli/dist/tui/commands.js
|
|
30011
30157
|
async function handleSlashCommand(input, ctx) {
|
|
30012
30158
|
const trimmed = input.trim();
|
|
@@ -30385,7 +30531,7 @@ async function handleSlashCommand(input, ctx) {
|
|
|
30385
30531
|
if (arg) {
|
|
30386
30532
|
await switchModel(arg, ctx, hasLocal);
|
|
30387
30533
|
} else {
|
|
30388
|
-
await showModelPicker(ctx);
|
|
30534
|
+
await showModelPicker(ctx, hasLocal);
|
|
30389
30535
|
}
|
|
30390
30536
|
return "handled";
|
|
30391
30537
|
case "models":
|
|
@@ -31121,14 +31267,29 @@ async function listModels(ctx) {
|
|
|
31121
31267
|
renderError(`Failed to fetch models: ${err instanceof Error ? err.message : String(err)}`);
|
|
31122
31268
|
}
|
|
31123
31269
|
}
|
|
31124
|
-
async function showModelPicker(ctx) {
|
|
31270
|
+
async function showModelPicker(ctx, local = false) {
|
|
31125
31271
|
try {
|
|
31126
31272
|
const models = await fetchModels(ctx.config.backendUrl, ctx.config.apiKey);
|
|
31127
31273
|
if (models.length === 0) {
|
|
31128
31274
|
renderWarning("No models found.");
|
|
31129
31275
|
return;
|
|
31130
31276
|
}
|
|
31131
|
-
|
|
31277
|
+
const items = models.map((m) => ({
|
|
31278
|
+
key: m.name,
|
|
31279
|
+
label: m.name,
|
|
31280
|
+
detail: [m.parameterSize, m.size, m.modified].filter(Boolean).join(" ")
|
|
31281
|
+
}));
|
|
31282
|
+
const result = await tuiSelect({
|
|
31283
|
+
items,
|
|
31284
|
+
activeKey: ctx.config.model,
|
|
31285
|
+
title: "Select Model",
|
|
31286
|
+
rl: ctx.rl
|
|
31287
|
+
});
|
|
31288
|
+
if (!result.confirmed || !result.key) {
|
|
31289
|
+
renderInfo("Model selection cancelled.");
|
|
31290
|
+
return;
|
|
31291
|
+
}
|
|
31292
|
+
await switchModel(result.key, ctx, local);
|
|
31132
31293
|
} catch (err) {
|
|
31133
31294
|
renderError(`Failed to fetch models: ${err instanceof Error ? err.message : String(err)}`);
|
|
31134
31295
|
}
|
|
@@ -31583,6 +31744,7 @@ var init_commands = __esm({
|
|
|
31583
31744
|
init_setup();
|
|
31584
31745
|
init_listen();
|
|
31585
31746
|
init_dist();
|
|
31747
|
+
init_tui_select();
|
|
31586
31748
|
}
|
|
31587
31749
|
});
|
|
31588
31750
|
|
|
@@ -32432,7 +32594,7 @@ var init_dist7 = __esm({
|
|
|
32432
32594
|
|
|
32433
32595
|
// packages/cli/dist/tui/carousel.js
|
|
32434
32596
|
function fg(code, text) {
|
|
32435
|
-
return
|
|
32597
|
+
return isTTY4 ? `\x1B[38;5;${code}m${text}\x1B[0m` : text;
|
|
32436
32598
|
}
|
|
32437
32599
|
function displayWidth(str) {
|
|
32438
32600
|
let w = 0;
|
|
@@ -32470,11 +32632,11 @@ function createRow(phraseIndices, speed, direction, bank) {
|
|
|
32470
32632
|
const phrases = phraseIndices.map((i) => bank[i % bank.length]);
|
|
32471
32633
|
return { phrases, offset: 0, speed, direction, renderedPlain: "" };
|
|
32472
32634
|
}
|
|
32473
|
-
var
|
|
32635
|
+
var isTTY4, PHRASES, Carousel;
|
|
32474
32636
|
var init_carousel = __esm({
|
|
32475
32637
|
"packages/cli/dist/tui/carousel.js"() {
|
|
32476
32638
|
"use strict";
|
|
32477
|
-
|
|
32639
|
+
isTTY4 = process.stdout.isTTY ?? false;
|
|
32478
32640
|
PHRASES = [
|
|
32479
32641
|
// English
|
|
32480
32642
|
{ text: "freedom of information", color: 39 },
|
|
@@ -32583,7 +32745,7 @@ var init_carousel = __esm({
|
|
|
32583
32745
|
* Sets scroll region to row 5+ for all content/readline.
|
|
32584
32746
|
*/
|
|
32585
32747
|
start() {
|
|
32586
|
-
if (!
|
|
32748
|
+
if (!isTTY4)
|
|
32587
32749
|
return 0;
|
|
32588
32750
|
this.started = true;
|
|
32589
32751
|
const termRows = process.stdout.rows ?? 24;
|
|
@@ -32619,7 +32781,7 @@ var init_carousel = __esm({
|
|
|
32619
32781
|
* Row 4 is left blank as a separator.
|
|
32620
32782
|
*/
|
|
32621
32783
|
renderFrame() {
|
|
32622
|
-
if (!
|
|
32784
|
+
if (!isTTY4)
|
|
32623
32785
|
return;
|
|
32624
32786
|
let buf = "\x1B7";
|
|
32625
32787
|
buf += "\x1B[?7l";
|
|
@@ -32699,7 +32861,7 @@ var init_carousel = __esm({
|
|
|
32699
32861
|
process.stdout.removeListener("resize", this.resizeHandler);
|
|
32700
32862
|
this.resizeHandler = null;
|
|
32701
32863
|
}
|
|
32702
|
-
if (!
|
|
32864
|
+
if (!isTTY4 || !this.started)
|
|
32703
32865
|
return;
|
|
32704
32866
|
let buf = "\x1B7";
|
|
32705
32867
|
for (let i = 0; i < this.reservedRows; i++) {
|
|
@@ -34859,26 +35021,26 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
|
34859
35021
|
});
|
|
34860
35022
|
|
|
34861
35023
|
// packages/cli/dist/tui/stream-renderer.js
|
|
34862
|
-
function
|
|
34863
|
-
return
|
|
35024
|
+
function fg2563(code, text) {
|
|
35025
|
+
return isTTY5 ? `\x1B[38;5;${code}m${text}\x1B[0m` : text;
|
|
34864
35026
|
}
|
|
34865
35027
|
function dimText(text) {
|
|
34866
|
-
return
|
|
35028
|
+
return isTTY5 ? `\x1B[2m${text}\x1B[0m` : text;
|
|
34867
35029
|
}
|
|
34868
35030
|
function italicText(text) {
|
|
34869
|
-
return
|
|
35031
|
+
return isTTY5 ? `\x1B[3m${text}\x1B[0m` : text;
|
|
34870
35032
|
}
|
|
34871
35033
|
function dimItalic(text) {
|
|
34872
|
-
return
|
|
35034
|
+
return isTTY5 ? `\x1B[2;3m${text}\x1B[0m` : text;
|
|
34873
35035
|
}
|
|
34874
35036
|
function boldText(text) {
|
|
34875
|
-
return
|
|
35037
|
+
return isTTY5 ? `\x1B[1m${text}\x1B[0m` : text;
|
|
34876
35038
|
}
|
|
34877
|
-
var
|
|
35039
|
+
var isTTY5, PASTEL, StreamRenderer;
|
|
34878
35040
|
var init_stream_renderer = __esm({
|
|
34879
35041
|
"packages/cli/dist/tui/stream-renderer.js"() {
|
|
34880
35042
|
"use strict";
|
|
34881
|
-
|
|
35043
|
+
isTTY5 = process.stdout.isTTY ?? false;
|
|
34882
35044
|
PASTEL = {
|
|
34883
35045
|
key: 222,
|
|
34884
35046
|
// light gold — JSON keys
|
|
@@ -35192,12 +35354,12 @@ var init_stream_renderer = __esm({
|
|
|
35192
35354
|
const colorKey = dim ? PASTEL.toolArg : PASTEL.key;
|
|
35193
35355
|
const colorStr = dim ? PASTEL.toolArg : PASTEL.string;
|
|
35194
35356
|
let result = line;
|
|
35195
|
-
result = result.replace(/"([^"]*)"(\s*:)/g, (_m, key, colon) =>
|
|
35196
|
-
result = result.replace(/(:\s*)"([^"]*)"/g, (_m, prefix, val) =>
|
|
35197
|
-
result = result.replace(/(:\s*)(\d+\.?\d*)/g, (_m, prefix, num) =>
|
|
35198
|
-
result = result.replace(/(:\s*)(true|false)/g, (_m, prefix, bool) =>
|
|
35199
|
-
result = result.replace(/(:\s*)(null)/g, (_m, prefix, n) =>
|
|
35200
|
-
result = result.replace(/([{}[\]])/g, (_m, b) =>
|
|
35357
|
+
result = result.replace(/"([^"]*)"(\s*:)/g, (_m, key, colon) => fg2563(colorKey, `"${key}"`) + fg2563(PASTEL.colon, colon));
|
|
35358
|
+
result = result.replace(/(:\s*)"([^"]*)"/g, (_m, prefix, val) => fg2563(PASTEL.colon, prefix) + fg2563(colorStr, `"${val}"`));
|
|
35359
|
+
result = result.replace(/(:\s*)(\d+\.?\d*)/g, (_m, prefix, num) => fg2563(PASTEL.colon, prefix) + fg2563(PASTEL.number, num));
|
|
35360
|
+
result = result.replace(/(:\s*)(true|false)/g, (_m, prefix, bool) => fg2563(PASTEL.colon, prefix) + fg2563(PASTEL.boolean, bool));
|
|
35361
|
+
result = result.replace(/(:\s*)(null)/g, (_m, prefix, n) => fg2563(PASTEL.colon, prefix) + fg2563(PASTEL.null, n));
|
|
35362
|
+
result = result.replace(/([{}[\]])/g, (_m, b) => fg2563(PASTEL.bracket, b));
|
|
35201
35363
|
return dim ? dimText(result) : result;
|
|
35202
35364
|
}
|
|
35203
35365
|
/**
|
|
@@ -35205,13 +35367,13 @@ var init_stream_renderer = __esm({
|
|
|
35205
35367
|
*/
|
|
35206
35368
|
highlightCode(line) {
|
|
35207
35369
|
let result = line;
|
|
35208
|
-
result = result.replace(/"([^"]*)"/g, (_m, s) =>
|
|
35209
|
-
result = result.replace(/'([^']*)'/g, (_m, s) =>
|
|
35210
|
-
result = result.replace(/\b(\d+\.?\d*)\b/g, (_m, n) =>
|
|
35211
|
-
result = result.replace(/\b(true|false|null|undefined|None|True|False)\b/g, (_m, kw) =>
|
|
35212
|
-
result = result.replace(/\b(function|const|let|var|return|if|else|for|while|import|export|from|class|async|await|def|self|try|catch|finally|throw|new|typeof|instanceof|type|interface|enum|struct|impl|fn|pub|mod|use|match|trait|where|mut|ref|move|yield|switch|case|default|break|continue|do|in|of|extends|implements|super|this|static|abstract|override|readonly|declare|namespace|package|func|go|chan|select|defer|range|map)\b/g, (_m, kw) =>
|
|
35213
|
-
result = result.replace(/:\s*([A-Z]\w*)/g, (_m, t) => ": " +
|
|
35214
|
-
result = result.replace(/(\/\/.*$|#.*$)/gm, (_m, cm) =>
|
|
35370
|
+
result = result.replace(/"([^"]*)"/g, (_m, s) => fg2563(PASTEL.string, `"${s}"`));
|
|
35371
|
+
result = result.replace(/'([^']*)'/g, (_m, s) => fg2563(PASTEL.string, `'${s}'`));
|
|
35372
|
+
result = result.replace(/\b(\d+\.?\d*)\b/g, (_m, n) => fg2563(PASTEL.number, n));
|
|
35373
|
+
result = result.replace(/\b(true|false|null|undefined|None|True|False)\b/g, (_m, kw) => fg2563(PASTEL.boolean, kw));
|
|
35374
|
+
result = result.replace(/\b(function|const|let|var|return|if|else|for|while|import|export|from|class|async|await|def|self|try|catch|finally|throw|new|typeof|instanceof|type|interface|enum|struct|impl|fn|pub|mod|use|match|trait|where|mut|ref|move|yield|switch|case|default|break|continue|do|in|of|extends|implements|super|this|static|abstract|override|readonly|declare|namespace|package|func|go|chan|select|defer|range|map)\b/g, (_m, kw) => fg2563(PASTEL.keyword, kw));
|
|
35375
|
+
result = result.replace(/:\s*([A-Z]\w*)/g, (_m, t) => ": " + fg2563(147, t));
|
|
35376
|
+
result = result.replace(/(\/\/.*$|#.*$)/gm, (_m, cm) => fg2563(PASTEL.comment, cm));
|
|
35215
35377
|
return result;
|
|
35216
35378
|
}
|
|
35217
35379
|
// -------------------------------------------------------------------------
|
|
@@ -35223,30 +35385,30 @@ var init_stream_renderer = __esm({
|
|
|
35223
35385
|
*/
|
|
35224
35386
|
highlightDiff(line) {
|
|
35225
35387
|
if (/^[-]{3}\s/.test(line) || /^[+]{3}\s/.test(line)) {
|
|
35226
|
-
return boldText(
|
|
35388
|
+
return boldText(fg2563(PASTEL.diffMeta, line));
|
|
35227
35389
|
}
|
|
35228
35390
|
if (line.startsWith("@@")) {
|
|
35229
|
-
return
|
|
35391
|
+
return fg2563(PASTEL.diffHunk, line);
|
|
35230
35392
|
}
|
|
35231
35393
|
if (line.startsWith("diff ") || line.startsWith("index ")) {
|
|
35232
|
-
return
|
|
35394
|
+
return fg2563(PASTEL.diffMeta, line);
|
|
35233
35395
|
}
|
|
35234
35396
|
if (line.startsWith("+")) {
|
|
35235
|
-
return
|
|
35397
|
+
return fg2563(PASTEL.diffAdded, line);
|
|
35236
35398
|
}
|
|
35237
35399
|
if (line.startsWith("-")) {
|
|
35238
|
-
return
|
|
35400
|
+
return fg2563(PASTEL.diffRemoved, line);
|
|
35239
35401
|
}
|
|
35240
35402
|
if (/^\s*\d+\s*[+-]\s/.test(line)) {
|
|
35241
35403
|
const match = line.match(/^(\s*\d+\s*)([+-])(\s.*)$/);
|
|
35242
35404
|
if (match) {
|
|
35243
|
-
const num =
|
|
35244
|
-
const sign = match[2] === "+" ?
|
|
35245
|
-
const rest = match[2] === "+" ?
|
|
35405
|
+
const num = fg2563(PASTEL.diffContext, match[1]);
|
|
35406
|
+
const sign = match[2] === "+" ? fg2563(PASTEL.diffAdded, "+") : fg2563(PASTEL.diffRemoved, "-");
|
|
35407
|
+
const rest = match[2] === "+" ? fg2563(PASTEL.diffAdded, match[3]) : fg2563(PASTEL.diffRemoved, match[3]);
|
|
35246
35408
|
return num + sign + rest;
|
|
35247
35409
|
}
|
|
35248
35410
|
}
|
|
35249
|
-
return
|
|
35411
|
+
return fg2563(PASTEL.diffContext, line);
|
|
35250
35412
|
}
|
|
35251
35413
|
// -------------------------------------------------------------------------
|
|
35252
35414
|
// Shell / bash highlighting
|
|
@@ -35256,16 +35418,16 @@ var init_stream_renderer = __esm({
|
|
|
35256
35418
|
*/
|
|
35257
35419
|
highlightShell(line) {
|
|
35258
35420
|
if (/^\s*#/.test(line)) {
|
|
35259
|
-
return
|
|
35421
|
+
return fg2563(PASTEL.comment, line);
|
|
35260
35422
|
}
|
|
35261
35423
|
let result = line;
|
|
35262
|
-
result = result.replace(/"([^"]*)"/g, (_m, s) =>
|
|
35263
|
-
result = result.replace(/'([^']*)'/g, (_m, s) =>
|
|
35264
|
-
result = result.replace(/(\$\{[^}]+\}|\$[A-Za-z_]\w*|\$[0-9?@#*!$-])/g, (_m, v) =>
|
|
35265
|
-
result = result.replace(/((?:^|\s))(--?[a-zA-Z][\w-]*)/g, (_m, ws, flag) => ws +
|
|
35266
|
-
result = result.replace(/(\|{1,2}|>{1,2}|<{1,2}|&{1,2}|;)/g, (_m, op) =>
|
|
35267
|
-
result = result.replace(/^(\s*)(npm|npx|node|pnpm|yarn|git|docker|kubectl|curl|wget|cat|grep|find|ls|cd|cp|mv|rm|mkdir|chmod|chown|echo|printf|sed|awk|sort|uniq|head|tail|wc|tar|gzip|make|cargo|go|pip|python|python3|ruby|gem|brew|apt|yum|dnf|pacman|sudo|ssh|scp|rsync|man)\b/, (_m, ws, cmd) => ws + boldText(
|
|
35268
|
-
result = result.replace(/(#[^{].*$)/gm, (_m, cm) =>
|
|
35424
|
+
result = result.replace(/"([^"]*)"/g, (_m, s) => fg2563(PASTEL.string, `"${s}"`));
|
|
35425
|
+
result = result.replace(/'([^']*)'/g, (_m, s) => fg2563(PASTEL.string, `'${s}'`));
|
|
35426
|
+
result = result.replace(/(\$\{[^}]+\}|\$[A-Za-z_]\w*|\$[0-9?@#*!$-])/g, (_m, v) => fg2563(PASTEL.shellVar, v));
|
|
35427
|
+
result = result.replace(/((?:^|\s))(--?[a-zA-Z][\w-]*)/g, (_m, ws, flag) => ws + fg2563(PASTEL.shellFlag, flag));
|
|
35428
|
+
result = result.replace(/(\|{1,2}|>{1,2}|<{1,2}|&{1,2}|;)/g, (_m, op) => fg2563(PASTEL.shellOp, op));
|
|
35429
|
+
result = result.replace(/^(\s*)(npm|npx|node|pnpm|yarn|git|docker|kubectl|curl|wget|cat|grep|find|ls|cd|cp|mv|rm|mkdir|chmod|chown|echo|printf|sed|awk|sort|uniq|head|tail|wc|tar|gzip|make|cargo|go|pip|python|python3|ruby|gem|brew|apt|yum|dnf|pacman|sudo|ssh|scp|rsync|man)\b/, (_m, ws, cmd) => ws + boldText(fg2563(PASTEL.keyword, cmd)));
|
|
35430
|
+
result = result.replace(/(#[^{].*$)/gm, (_m, cm) => fg2563(PASTEL.comment, cm));
|
|
35269
35431
|
return result;
|
|
35270
35432
|
}
|
|
35271
35433
|
// -------------------------------------------------------------------------
|
|
@@ -35280,23 +35442,23 @@ var init_stream_renderer = __esm({
|
|
|
35280
35442
|
const level = headingMatch[1].length;
|
|
35281
35443
|
const text = headingMatch[2];
|
|
35282
35444
|
const colors = [PASTEL.heading1, PASTEL.heading2, PASTEL.heading3, PASTEL.heading3, 183, 183];
|
|
35283
|
-
return boldText(
|
|
35445
|
+
return boldText(fg2563(colors[level - 1] ?? 147, text));
|
|
35284
35446
|
}
|
|
35285
35447
|
if (/^[-*_]{3,}\s*$/.test(line)) {
|
|
35286
35448
|
const w = (process.stdout.columns ?? 80) - 10;
|
|
35287
|
-
return
|
|
35449
|
+
return fg2563(PASTEL.hr, "\u2500".repeat(Math.min(w, 60)));
|
|
35288
35450
|
}
|
|
35289
35451
|
if (/^>\s?/.test(line)) {
|
|
35290
35452
|
const content = line.replace(/^>\s?/, "");
|
|
35291
|
-
return
|
|
35453
|
+
return fg2563(PASTEL.blockquote, "\u2502 ") + italicText(fg2563(PASTEL.blockquote, this.highlightInline(content)));
|
|
35292
35454
|
}
|
|
35293
35455
|
const ulMatch = line.match(/^(\s*)([-*+])\s+(.*)/);
|
|
35294
35456
|
if (ulMatch) {
|
|
35295
|
-
return ulMatch[1] +
|
|
35457
|
+
return ulMatch[1] + fg2563(PASTEL.blockquote, "\u2022") + " " + this.highlightInline(ulMatch[3]);
|
|
35296
35458
|
}
|
|
35297
35459
|
const olMatch = line.match(/^(\s*)(\d+[.)])\s+(.*)/);
|
|
35298
35460
|
if (olMatch) {
|
|
35299
|
-
return olMatch[1] +
|
|
35461
|
+
return olMatch[1] + fg2563(PASTEL.blockquote, olMatch[2]) + " " + this.highlightInline(olMatch[3]);
|
|
35300
35462
|
}
|
|
35301
35463
|
return this.highlightInline(line);
|
|
35302
35464
|
}
|
|
@@ -35305,11 +35467,11 @@ var init_stream_renderer = __esm({
|
|
|
35305
35467
|
*/
|
|
35306
35468
|
highlightInline(text) {
|
|
35307
35469
|
let result = text;
|
|
35308
|
-
result = result.replace(/`([^`]+)`/g, (_m, code) =>
|
|
35470
|
+
result = result.replace(/`([^`]+)`/g, (_m, code) => fg2563(PASTEL.inlineCode, code));
|
|
35309
35471
|
result = result.replace(/\*{3}([^*]+)\*{3}/g, (_m, t) => boldText(italicText(t)));
|
|
35310
35472
|
result = result.replace(/\*{2}([^*]+)\*{2}/g, (_m, t) => boldText(t));
|
|
35311
35473
|
result = result.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g, (_m, t) => italicText(t));
|
|
35312
|
-
result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m, label, url) => boldText(
|
|
35474
|
+
result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m, label, url) => boldText(fg2563(PASTEL.link, label)) + " " + dimText(fg2563(PASTEL.link, `(${url})`)));
|
|
35313
35475
|
result = result.replace(/__([^_]+)__/g, (_m, t) => boldText(t));
|
|
35314
35476
|
result = result.replace(/(?<!_)_([^_]+)_(?!_)/g, (_m, t) => italicText(t));
|
|
35315
35477
|
result = result.replace(/~~([^~]+)~~/g, (_m, t) => dimText(t));
|
package/package.json
CHANGED