open-agents-ai 0.103.4 → 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 +241 -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
|
}
|
|
@@ -31255,6 +31416,31 @@ async function handleEndpoint(arg, ctx, local = false) {
|
|
|
31255
31416
|
`);
|
|
31256
31417
|
}
|
|
31257
31418
|
process.stdout.write("\n");
|
|
31419
|
+
try {
|
|
31420
|
+
const newModels = await fetchModels(normalizedUrl, apiKey);
|
|
31421
|
+
if (newModels.length > 0) {
|
|
31422
|
+
const currentModel = ctx.config.model;
|
|
31423
|
+
const found = findModel(newModels, currentModel);
|
|
31424
|
+
if (!found) {
|
|
31425
|
+
const autoModel = newModels[0].name;
|
|
31426
|
+
const oldModel = currentModel;
|
|
31427
|
+
ctx.setModel(autoModel);
|
|
31428
|
+
if (local) {
|
|
31429
|
+
ctx.saveLocalSettings({ model: autoModel });
|
|
31430
|
+
} else {
|
|
31431
|
+
ctx.saveSettings({ model: autoModel });
|
|
31432
|
+
}
|
|
31433
|
+
renderWarning(`Model "${oldModel}" not found on ${provider.label}.`);
|
|
31434
|
+
renderModelSwitch(oldModel, autoModel);
|
|
31435
|
+
} else {
|
|
31436
|
+
process.stdout.write(` ${c2.green("\u2714")} Model "${ctx.config.model}" available on ${provider.label}.
|
|
31437
|
+
|
|
31438
|
+
`);
|
|
31439
|
+
}
|
|
31440
|
+
}
|
|
31441
|
+
} catch {
|
|
31442
|
+
renderWarning(`Could not verify model availability on ${provider.label}. If inference fails, use /model to switch.`);
|
|
31443
|
+
}
|
|
31258
31444
|
}
|
|
31259
31445
|
async function handleUpdate(subcommand, ctx) {
|
|
31260
31446
|
const repoRoot = ctx.repoRoot;
|
|
@@ -31558,6 +31744,7 @@ var init_commands = __esm({
|
|
|
31558
31744
|
init_setup();
|
|
31559
31745
|
init_listen();
|
|
31560
31746
|
init_dist();
|
|
31747
|
+
init_tui_select();
|
|
31561
31748
|
}
|
|
31562
31749
|
});
|
|
31563
31750
|
|
|
@@ -32407,7 +32594,7 @@ var init_dist7 = __esm({
|
|
|
32407
32594
|
|
|
32408
32595
|
// packages/cli/dist/tui/carousel.js
|
|
32409
32596
|
function fg(code, text) {
|
|
32410
|
-
return
|
|
32597
|
+
return isTTY4 ? `\x1B[38;5;${code}m${text}\x1B[0m` : text;
|
|
32411
32598
|
}
|
|
32412
32599
|
function displayWidth(str) {
|
|
32413
32600
|
let w = 0;
|
|
@@ -32445,11 +32632,11 @@ function createRow(phraseIndices, speed, direction, bank) {
|
|
|
32445
32632
|
const phrases = phraseIndices.map((i) => bank[i % bank.length]);
|
|
32446
32633
|
return { phrases, offset: 0, speed, direction, renderedPlain: "" };
|
|
32447
32634
|
}
|
|
32448
|
-
var
|
|
32635
|
+
var isTTY4, PHRASES, Carousel;
|
|
32449
32636
|
var init_carousel = __esm({
|
|
32450
32637
|
"packages/cli/dist/tui/carousel.js"() {
|
|
32451
32638
|
"use strict";
|
|
32452
|
-
|
|
32639
|
+
isTTY4 = process.stdout.isTTY ?? false;
|
|
32453
32640
|
PHRASES = [
|
|
32454
32641
|
// English
|
|
32455
32642
|
{ text: "freedom of information", color: 39 },
|
|
@@ -32558,7 +32745,7 @@ var init_carousel = __esm({
|
|
|
32558
32745
|
* Sets scroll region to row 5+ for all content/readline.
|
|
32559
32746
|
*/
|
|
32560
32747
|
start() {
|
|
32561
|
-
if (!
|
|
32748
|
+
if (!isTTY4)
|
|
32562
32749
|
return 0;
|
|
32563
32750
|
this.started = true;
|
|
32564
32751
|
const termRows = process.stdout.rows ?? 24;
|
|
@@ -32594,7 +32781,7 @@ var init_carousel = __esm({
|
|
|
32594
32781
|
* Row 4 is left blank as a separator.
|
|
32595
32782
|
*/
|
|
32596
32783
|
renderFrame() {
|
|
32597
|
-
if (!
|
|
32784
|
+
if (!isTTY4)
|
|
32598
32785
|
return;
|
|
32599
32786
|
let buf = "\x1B7";
|
|
32600
32787
|
buf += "\x1B[?7l";
|
|
@@ -32674,7 +32861,7 @@ var init_carousel = __esm({
|
|
|
32674
32861
|
process.stdout.removeListener("resize", this.resizeHandler);
|
|
32675
32862
|
this.resizeHandler = null;
|
|
32676
32863
|
}
|
|
32677
|
-
if (!
|
|
32864
|
+
if (!isTTY4 || !this.started)
|
|
32678
32865
|
return;
|
|
32679
32866
|
let buf = "\x1B7";
|
|
32680
32867
|
for (let i = 0; i < this.reservedRows; i++) {
|
|
@@ -34834,26 +35021,26 @@ Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
|
34834
35021
|
});
|
|
34835
35022
|
|
|
34836
35023
|
// packages/cli/dist/tui/stream-renderer.js
|
|
34837
|
-
function
|
|
34838
|
-
return
|
|
35024
|
+
function fg2563(code, text) {
|
|
35025
|
+
return isTTY5 ? `\x1B[38;5;${code}m${text}\x1B[0m` : text;
|
|
34839
35026
|
}
|
|
34840
35027
|
function dimText(text) {
|
|
34841
|
-
return
|
|
35028
|
+
return isTTY5 ? `\x1B[2m${text}\x1B[0m` : text;
|
|
34842
35029
|
}
|
|
34843
35030
|
function italicText(text) {
|
|
34844
|
-
return
|
|
35031
|
+
return isTTY5 ? `\x1B[3m${text}\x1B[0m` : text;
|
|
34845
35032
|
}
|
|
34846
35033
|
function dimItalic(text) {
|
|
34847
|
-
return
|
|
35034
|
+
return isTTY5 ? `\x1B[2;3m${text}\x1B[0m` : text;
|
|
34848
35035
|
}
|
|
34849
35036
|
function boldText(text) {
|
|
34850
|
-
return
|
|
35037
|
+
return isTTY5 ? `\x1B[1m${text}\x1B[0m` : text;
|
|
34851
35038
|
}
|
|
34852
|
-
var
|
|
35039
|
+
var isTTY5, PASTEL, StreamRenderer;
|
|
34853
35040
|
var init_stream_renderer = __esm({
|
|
34854
35041
|
"packages/cli/dist/tui/stream-renderer.js"() {
|
|
34855
35042
|
"use strict";
|
|
34856
|
-
|
|
35043
|
+
isTTY5 = process.stdout.isTTY ?? false;
|
|
34857
35044
|
PASTEL = {
|
|
34858
35045
|
key: 222,
|
|
34859
35046
|
// light gold — JSON keys
|
|
@@ -35167,12 +35354,12 @@ var init_stream_renderer = __esm({
|
|
|
35167
35354
|
const colorKey = dim ? PASTEL.toolArg : PASTEL.key;
|
|
35168
35355
|
const colorStr = dim ? PASTEL.toolArg : PASTEL.string;
|
|
35169
35356
|
let result = line;
|
|
35170
|
-
result = result.replace(/"([^"]*)"(\s*:)/g, (_m, key, colon) =>
|
|
35171
|
-
result = result.replace(/(:\s*)"([^"]*)"/g, (_m, prefix, val) =>
|
|
35172
|
-
result = result.replace(/(:\s*)(\d+\.?\d*)/g, (_m, prefix, num) =>
|
|
35173
|
-
result = result.replace(/(:\s*)(true|false)/g, (_m, prefix, bool) =>
|
|
35174
|
-
result = result.replace(/(:\s*)(null)/g, (_m, prefix, n) =>
|
|
35175
|
-
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));
|
|
35176
35363
|
return dim ? dimText(result) : result;
|
|
35177
35364
|
}
|
|
35178
35365
|
/**
|
|
@@ -35180,13 +35367,13 @@ var init_stream_renderer = __esm({
|
|
|
35180
35367
|
*/
|
|
35181
35368
|
highlightCode(line) {
|
|
35182
35369
|
let result = line;
|
|
35183
|
-
result = result.replace(/"([^"]*)"/g, (_m, s) =>
|
|
35184
|
-
result = result.replace(/'([^']*)'/g, (_m, s) =>
|
|
35185
|
-
result = result.replace(/\b(\d+\.?\d*)\b/g, (_m, n) =>
|
|
35186
|
-
result = result.replace(/\b(true|false|null|undefined|None|True|False)\b/g, (_m, kw) =>
|
|
35187
|
-
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) =>
|
|
35188
|
-
result = result.replace(/:\s*([A-Z]\w*)/g, (_m, t) => ": " +
|
|
35189
|
-
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));
|
|
35190
35377
|
return result;
|
|
35191
35378
|
}
|
|
35192
35379
|
// -------------------------------------------------------------------------
|
|
@@ -35198,30 +35385,30 @@ var init_stream_renderer = __esm({
|
|
|
35198
35385
|
*/
|
|
35199
35386
|
highlightDiff(line) {
|
|
35200
35387
|
if (/^[-]{3}\s/.test(line) || /^[+]{3}\s/.test(line)) {
|
|
35201
|
-
return boldText(
|
|
35388
|
+
return boldText(fg2563(PASTEL.diffMeta, line));
|
|
35202
35389
|
}
|
|
35203
35390
|
if (line.startsWith("@@")) {
|
|
35204
|
-
return
|
|
35391
|
+
return fg2563(PASTEL.diffHunk, line);
|
|
35205
35392
|
}
|
|
35206
35393
|
if (line.startsWith("diff ") || line.startsWith("index ")) {
|
|
35207
|
-
return
|
|
35394
|
+
return fg2563(PASTEL.diffMeta, line);
|
|
35208
35395
|
}
|
|
35209
35396
|
if (line.startsWith("+")) {
|
|
35210
|
-
return
|
|
35397
|
+
return fg2563(PASTEL.diffAdded, line);
|
|
35211
35398
|
}
|
|
35212
35399
|
if (line.startsWith("-")) {
|
|
35213
|
-
return
|
|
35400
|
+
return fg2563(PASTEL.diffRemoved, line);
|
|
35214
35401
|
}
|
|
35215
35402
|
if (/^\s*\d+\s*[+-]\s/.test(line)) {
|
|
35216
35403
|
const match = line.match(/^(\s*\d+\s*)([+-])(\s.*)$/);
|
|
35217
35404
|
if (match) {
|
|
35218
|
-
const num =
|
|
35219
|
-
const sign = match[2] === "+" ?
|
|
35220
|
-
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]);
|
|
35221
35408
|
return num + sign + rest;
|
|
35222
35409
|
}
|
|
35223
35410
|
}
|
|
35224
|
-
return
|
|
35411
|
+
return fg2563(PASTEL.diffContext, line);
|
|
35225
35412
|
}
|
|
35226
35413
|
// -------------------------------------------------------------------------
|
|
35227
35414
|
// Shell / bash highlighting
|
|
@@ -35231,16 +35418,16 @@ var init_stream_renderer = __esm({
|
|
|
35231
35418
|
*/
|
|
35232
35419
|
highlightShell(line) {
|
|
35233
35420
|
if (/^\s*#/.test(line)) {
|
|
35234
|
-
return
|
|
35421
|
+
return fg2563(PASTEL.comment, line);
|
|
35235
35422
|
}
|
|
35236
35423
|
let result = line;
|
|
35237
|
-
result = result.replace(/"([^"]*)"/g, (_m, s) =>
|
|
35238
|
-
result = result.replace(/'([^']*)'/g, (_m, s) =>
|
|
35239
|
-
result = result.replace(/(\$\{[^}]+\}|\$[A-Za-z_]\w*|\$[0-9?@#*!$-])/g, (_m, v) =>
|
|
35240
|
-
result = result.replace(/((?:^|\s))(--?[a-zA-Z][\w-]*)/g, (_m, ws, flag) => ws +
|
|
35241
|
-
result = result.replace(/(\|{1,2}|>{1,2}|<{1,2}|&{1,2}|;)/g, (_m, op) =>
|
|
35242
|
-
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(
|
|
35243
|
-
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));
|
|
35244
35431
|
return result;
|
|
35245
35432
|
}
|
|
35246
35433
|
// -------------------------------------------------------------------------
|
|
@@ -35255,23 +35442,23 @@ var init_stream_renderer = __esm({
|
|
|
35255
35442
|
const level = headingMatch[1].length;
|
|
35256
35443
|
const text = headingMatch[2];
|
|
35257
35444
|
const colors = [PASTEL.heading1, PASTEL.heading2, PASTEL.heading3, PASTEL.heading3, 183, 183];
|
|
35258
|
-
return boldText(
|
|
35445
|
+
return boldText(fg2563(colors[level - 1] ?? 147, text));
|
|
35259
35446
|
}
|
|
35260
35447
|
if (/^[-*_]{3,}\s*$/.test(line)) {
|
|
35261
35448
|
const w = (process.stdout.columns ?? 80) - 10;
|
|
35262
|
-
return
|
|
35449
|
+
return fg2563(PASTEL.hr, "\u2500".repeat(Math.min(w, 60)));
|
|
35263
35450
|
}
|
|
35264
35451
|
if (/^>\s?/.test(line)) {
|
|
35265
35452
|
const content = line.replace(/^>\s?/, "");
|
|
35266
|
-
return
|
|
35453
|
+
return fg2563(PASTEL.blockquote, "\u2502 ") + italicText(fg2563(PASTEL.blockquote, this.highlightInline(content)));
|
|
35267
35454
|
}
|
|
35268
35455
|
const ulMatch = line.match(/^(\s*)([-*+])\s+(.*)/);
|
|
35269
35456
|
if (ulMatch) {
|
|
35270
|
-
return ulMatch[1] +
|
|
35457
|
+
return ulMatch[1] + fg2563(PASTEL.blockquote, "\u2022") + " " + this.highlightInline(ulMatch[3]);
|
|
35271
35458
|
}
|
|
35272
35459
|
const olMatch = line.match(/^(\s*)(\d+[.)])\s+(.*)/);
|
|
35273
35460
|
if (olMatch) {
|
|
35274
|
-
return olMatch[1] +
|
|
35461
|
+
return olMatch[1] + fg2563(PASTEL.blockquote, olMatch[2]) + " " + this.highlightInline(olMatch[3]);
|
|
35275
35462
|
}
|
|
35276
35463
|
return this.highlightInline(line);
|
|
35277
35464
|
}
|
|
@@ -35280,11 +35467,11 @@ var init_stream_renderer = __esm({
|
|
|
35280
35467
|
*/
|
|
35281
35468
|
highlightInline(text) {
|
|
35282
35469
|
let result = text;
|
|
35283
|
-
result = result.replace(/`([^`]+)`/g, (_m, code) =>
|
|
35470
|
+
result = result.replace(/`([^`]+)`/g, (_m, code) => fg2563(PASTEL.inlineCode, code));
|
|
35284
35471
|
result = result.replace(/\*{3}([^*]+)\*{3}/g, (_m, t) => boldText(italicText(t)));
|
|
35285
35472
|
result = result.replace(/\*{2}([^*]+)\*{2}/g, (_m, t) => boldText(t));
|
|
35286
35473
|
result = result.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g, (_m, t) => italicText(t));
|
|
35287
|
-
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})`)));
|
|
35288
35475
|
result = result.replace(/__([^_]+)__/g, (_m, t) => boldText(t));
|
|
35289
35476
|
result = result.replace(/(?<!_)_([^_]+)_(?!_)/g, (_m, t) => italicText(t));
|
|
35290
35477
|
result = result.replace(/~~([^~]+)~~/g, (_m, t) => dimText(t));
|
package/package.json
CHANGED