scream-code 0.4.1 → 0.4.2
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/main.mjs +181 -152
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -85268,6 +85268,11 @@ async function runToolCallBatch(step, response) {
|
|
|
85268
85268
|
try {
|
|
85269
85269
|
for (let index = 0; index < calls.length; index += 1) {
|
|
85270
85270
|
const call = calls[index];
|
|
85271
|
+
if (step.signal.aborted) {
|
|
85272
|
+
await dispatchToolCall(step, call, call.args);
|
|
85273
|
+
pendingResults.push(Promise.resolve(makeErrorToolResult(call, call.args, abortedToolOutput(call.toolName, step.signal))));
|
|
85274
|
+
continue;
|
|
85275
|
+
}
|
|
85271
85276
|
const prepared = await prepareToolCall(step, call);
|
|
85272
85277
|
pendingResults.push(scheduler.add(prepared.task));
|
|
85273
85278
|
if (prepared.stopBatchAfterThis === true) {
|
|
@@ -131527,6 +131532,15 @@ function createTUIState(options) {
|
|
|
131527
131532
|
const theme = createScreamTUIThemeBundle(initialAppState.theme, options.resolvedTheme);
|
|
131528
131533
|
const terminal = new ProcessTerminal();
|
|
131529
131534
|
const ui = new TUI(terminal);
|
|
131535
|
+
const uiAny = ui;
|
|
131536
|
+
const originalDoRender = uiAny["doRender"].bind(ui);
|
|
131537
|
+
uiAny["doRender"] = () => {
|
|
131538
|
+
try {
|
|
131539
|
+
originalDoRender();
|
|
131540
|
+
} catch (error) {
|
|
131541
|
+
console.error("[scream-code] render error:", error);
|
|
131542
|
+
}
|
|
131543
|
+
};
|
|
131530
131544
|
const transcriptContainer = new GutterContainer(1, 1);
|
|
131531
131545
|
const activityContainer = new GutterContainer(1, 1);
|
|
131532
131546
|
const todoPanelContainer = new GutterContainer(1, 1);
|
|
@@ -135376,112 +135390,114 @@ var ScreamTUI = class {
|
|
|
135376
135390
|
};
|
|
135377
135391
|
//#endregion
|
|
135378
135392
|
//#region src/tui/components/chrome/loading.ts
|
|
135379
|
-
const { stdout } = process$1;
|
|
135380
|
-
const
|
|
135381
|
-
|
|
135382
|
-
|
|
135383
|
-
|
|
135384
|
-
|
|
135393
|
+
const { stdout, stdin } = process$1;
|
|
135394
|
+
const LOGO = [
|
|
135395
|
+
"███████╗ ██████╗██████╗ ███████╗ █████╗ ███╗ ███╗ ██████╗ ██████╗ ██████╗ ███████╗",
|
|
135396
|
+
"██╔════╝██╔════╝██╔══██╗██╔════╝██╔══██╗████╗ ████║ ██╔════╝██╔═══██╗██╔══██╗██╔════╝",
|
|
135397
|
+
"███████╗██║ ██████╔╝█████╗ ███████║██╔████╔██║ ██║ ██║ ██║██║ ██║█████╗ ",
|
|
135398
|
+
"╚════██║██║ ██╔══██╗██╔══╝ ██╔══██║██║╚██╔╝██║ ██║ ██║ ██║██║ ██║██╔══╝ ",
|
|
135399
|
+
"███████║╚██████╗██║ ██║███████╗██║ ██║██║ ╚═╝ ██║ ╚██████╗╚██████╔╝██████╔╝███████╗",
|
|
135400
|
+
"╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝"
|
|
135401
|
+
];
|
|
135402
|
+
const SHADOW_CHARS = new Set([
|
|
135403
|
+
"╚",
|
|
135404
|
+
"═",
|
|
135405
|
+
"╝",
|
|
135406
|
+
"║",
|
|
135407
|
+
"╔",
|
|
135408
|
+
"╗",
|
|
135409
|
+
"╠",
|
|
135410
|
+
"╣",
|
|
135411
|
+
"╦",
|
|
135412
|
+
"╩",
|
|
135413
|
+
"╬"
|
|
135414
|
+
]);
|
|
135415
|
+
const SHEEN_STEP = 2;
|
|
135416
|
+
const SHEEN_INTERVAL_MS = 150;
|
|
135417
|
+
const THEME_ACCENT = {
|
|
135418
|
+
dark: [
|
|
135419
|
+
78,
|
|
135420
|
+
200,
|
|
135421
|
+
126
|
|
135422
|
+
],
|
|
135423
|
+
light: [
|
|
135424
|
+
14,
|
|
135425
|
+
122,
|
|
135426
|
+
56
|
|
135427
|
+
]
|
|
135385
135428
|
};
|
|
135386
|
-
const
|
|
135387
|
-
|
|
135388
|
-
|
|
135389
|
-
|
|
135390
|
-
"┌┐",
|
|
135391
|
-
"││",
|
|
135392
|
-
"││",
|
|
135393
|
-
"└┘"
|
|
135394
|
-
]
|
|
135395
|
-
},
|
|
135396
|
-
{
|
|
135397
|
-
duration: 80,
|
|
135398
|
-
content: [
|
|
135399
|
-
"┌──────┐",
|
|
135400
|
-
"│ │",
|
|
135401
|
-
"│ │",
|
|
135402
|
-
"└──────┘"
|
|
135403
|
-
]
|
|
135404
|
-
},
|
|
135405
|
-
{
|
|
135406
|
-
duration: 80,
|
|
135407
|
-
content: [
|
|
135408
|
-
"┌──────────────────┐",
|
|
135409
|
-
"│ │",
|
|
135410
|
-
"│ │",
|
|
135411
|
-
"└──────────────────┘"
|
|
135412
|
-
]
|
|
135413
|
-
},
|
|
135414
|
-
{
|
|
135415
|
-
duration: 80,
|
|
135416
|
-
content: [
|
|
135417
|
-
"┌──────────────────────────────┐",
|
|
135418
|
-
"│ │",
|
|
135419
|
-
"│ welcome to scream code │",
|
|
135420
|
-
"│ │",
|
|
135421
|
-
"└──────────────────────────────┘"
|
|
135422
|
-
]
|
|
135423
|
-
},
|
|
135424
|
-
{
|
|
135425
|
-
duration: 100,
|
|
135426
|
-
content: [
|
|
135427
|
-
"┌─────────────────────────────────────────────────────────────────┐",
|
|
135428
|
-
"│ │",
|
|
135429
|
-
"│ welcome to scream code │",
|
|
135430
|
-
"│ │",
|
|
135431
|
-
"│ ███████╗ ██████╗██████╗ ███████╗ █████╗ ███╗ ███╗ │",
|
|
135432
|
-
"│ ██╔════╝ ██╔════╝██╔══██╗██╔════╝██╔══██╗████╗ ████║ │",
|
|
135433
|
-
"│ ███████╗ ██║ ██████╔╝█████╗ ███████║██╔████╔██║ │",
|
|
135434
|
-
"│ ╚════██║ ██║ ██╔══██╗██╔══╝ ██╔══██║██║╚██╔╝██║ │",
|
|
135435
|
-
"│ ███████║ ╚██████╗██║ ██║███████╗██║ ██║██║ ╚═╝ ██║ │",
|
|
135436
|
-
"│ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ │",
|
|
135437
|
-
"│ │",
|
|
135438
|
-
"└─────────────────────────────────────────────────────────────────┘"
|
|
135439
|
-
]
|
|
135440
|
-
},
|
|
135441
|
-
{
|
|
135442
|
-
duration: 120,
|
|
135443
|
-
content: [
|
|
135444
|
-
"┌─────────────────────────────────────────────────────────────────┐",
|
|
135445
|
-
"│ │",
|
|
135446
|
-
"│ welcome to scream code │",
|
|
135447
|
-
"│ │",
|
|
135448
|
-
"│ ███████╗ ██████╗██████╗ ███████╗ █████╗ ███╗ ███╗ │",
|
|
135449
|
-
"│ ██╔════╝ ██╔════╝██╔══██╗██╔════╝██╔══██╗████╗ ████║ │",
|
|
135450
|
-
"│ ███████╗ ██║ ██████╔╝█████╗ ███████║██╔████╔██║ │",
|
|
135451
|
-
"│ ╚════██║ ██║ ██╔══██╗██╔══╝ ██╔══██║██║╚██╔╝██║ │",
|
|
135452
|
-
"│ ███████║ ╚██████╗██║ ██║███████╗██║ ██║██║ ╚═╝ ██║ │",
|
|
135453
|
-
"│ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ │",
|
|
135454
|
-
"│ │",
|
|
135455
|
-
"│ 你的中文智能Ai助手 │",
|
|
135456
|
-
"└─────────────────────────────────────────────────────────────────┘"
|
|
135457
|
-
]
|
|
135458
|
-
},
|
|
135459
|
-
{
|
|
135460
|
-
duration: 9999,
|
|
135461
|
-
content: [
|
|
135462
|
-
"┌─────────────────────────────────────────────────────────────────┐",
|
|
135463
|
-
"│ │",
|
|
135464
|
-
"│ welcome to scream code │",
|
|
135465
|
-
"│ │",
|
|
135466
|
-
"│ ███████╗ ██████╗██████╗ ███████╗ █████╗ ███╗ ███╗ │",
|
|
135467
|
-
"│ ██╔════╝ ██╔════╝██╔══██╗██╔════╝██╔══██╗████╗ ████║ │",
|
|
135468
|
-
"│ ███████╗ ██║ ██████╔╝█████╗ ███████║██╔████╔██║ │",
|
|
135469
|
-
"│ ╚════██║ ██║ ██╔══██╗██╔══╝ ██╔══██║██║╚██╔╝██║ │",
|
|
135470
|
-
"│ ███████║ ╚██████╗██║ ██║███████╗██║ ██║██║ ╚═╝ ██║ │",
|
|
135471
|
-
"│ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ │",
|
|
135472
|
-
"│ │",
|
|
135473
|
-
"│ 你的中文智能Ai助手 │",
|
|
135474
|
-
"└─────────────────────────────────────────────────────────────────┘"
|
|
135475
|
-
]
|
|
135476
|
-
}
|
|
135429
|
+
const BLOCK_RGB = [
|
|
135430
|
+
255,
|
|
135431
|
+
255,
|
|
135432
|
+
255
|
|
135477
135433
|
];
|
|
135478
|
-
|
|
135479
|
-
|
|
135480
|
-
|
|
135481
|
-
|
|
135482
|
-
|
|
135483
|
-
|
|
135484
|
-
|
|
135434
|
+
const LOGO_RGB = [
|
|
135435
|
+
136,
|
|
135436
|
+
136,
|
|
135437
|
+
136
|
|
135438
|
+
];
|
|
135439
|
+
const DIM_RGB = [
|
|
135440
|
+
85,
|
|
135441
|
+
85,
|
|
135442
|
+
85
|
|
135443
|
+
];
|
|
135444
|
+
function fg(r, g, b) {
|
|
135445
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
135446
|
+
}
|
|
135447
|
+
const RESET = "\x1B[0m";
|
|
135448
|
+
const BOLD = "\x1B[1m";
|
|
135449
|
+
const DIM = "\x1B[2m";
|
|
135450
|
+
function renderSheen(char, charIndex, sheenPos, isReversing, accent) {
|
|
135451
|
+
if (char === " ") return " ";
|
|
135452
|
+
if (char === "█") return `${fg(...BLOCK_RGB)}█${RESET}`;
|
|
135453
|
+
if (!SHADOW_CHARS.has(char)) return `${fg(...LOGO_RGB)}${char}${RESET}`;
|
|
135454
|
+
let color;
|
|
135455
|
+
if (isReversing) color = charIndex <= sheenPos ? LOGO_RGB : accent;
|
|
135456
|
+
else color = charIndex <= sheenPos ? accent : LOGO_RGB;
|
|
135457
|
+
return `${fg(...color)}${char}${RESET}`;
|
|
135458
|
+
}
|
|
135459
|
+
const LOADING_TEXT = "加载中...";
|
|
135460
|
+
function buildShimmerPalette(n, accent) {
|
|
135461
|
+
const size = Math.max(8, Math.min(20, Math.ceil(n * 1.5)));
|
|
135462
|
+
const palette = [];
|
|
135463
|
+
for (let i = 0; i < size; i++) {
|
|
135464
|
+
const t = i / (size - 1);
|
|
135465
|
+
palette.push([
|
|
135466
|
+
Math.round(accent[0] - t * accent[0] * .35),
|
|
135467
|
+
Math.round(accent[1] - t * accent[1] * .6),
|
|
135468
|
+
Math.round(accent[2] - t * accent[2] * .33)
|
|
135469
|
+
]);
|
|
135470
|
+
}
|
|
135471
|
+
return palette;
|
|
135472
|
+
}
|
|
135473
|
+
function renderShimmer(pulse, accent) {
|
|
135474
|
+
const chars = LOADING_TEXT.split("");
|
|
135475
|
+
const n = chars.length;
|
|
135476
|
+
const palette = buildShimmerPalette(n, accent);
|
|
135477
|
+
let out = "";
|
|
135478
|
+
for (let i = 0; i < n; i++) {
|
|
135479
|
+
const phase = (pulse - i + n) % n;
|
|
135480
|
+
const color = palette[phase];
|
|
135481
|
+
const ratio = n <= 1 ? 0 : phase / (n - 1);
|
|
135482
|
+
out += `${ratio < .23 ? BOLD : ratio < .69 ? "" : DIM}${fg(...color)}${chars[i]}${RESET}`;
|
|
135483
|
+
}
|
|
135484
|
+
return out;
|
|
135485
|
+
}
|
|
135486
|
+
function getTerminalSize() {
|
|
135487
|
+
return {
|
|
135488
|
+
cols: stdout.columns || 80,
|
|
135489
|
+
rows: stdout.rows || 24
|
|
135490
|
+
};
|
|
135491
|
+
}
|
|
135492
|
+
function visualWidth(s) {
|
|
135493
|
+
let w = 0;
|
|
135494
|
+
for (const ch of s.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "")) w += /[一-鿿 -〿-]/.test(ch) ? 2 : 1;
|
|
135495
|
+
return w;
|
|
135496
|
+
}
|
|
135497
|
+
function centerPad(text, width) {
|
|
135498
|
+
const plainW = visualWidth(text);
|
|
135499
|
+
const pad = Math.max(0, Math.floor((width - plainW) / 2));
|
|
135500
|
+
return " ".repeat(pad) + text;
|
|
135485
135501
|
}
|
|
135486
135502
|
let ansiSupported = null;
|
|
135487
135503
|
function supportsAnsi() {
|
|
@@ -135523,63 +135539,76 @@ function supportsAnsi() {
|
|
|
135523
135539
|
ansiSupported = false;
|
|
135524
135540
|
return false;
|
|
135525
135541
|
}
|
|
135526
|
-
function plainFrame(frameIndex, green) {
|
|
135527
|
-
const f = FRAMES[Math.min(frameIndex, FRAMES.length - 1)];
|
|
135528
|
-
let out = "";
|
|
135529
|
-
for (const l of f.content) out += color(l, green) + (l || " ") + "\x1B[0m\n";
|
|
135530
|
-
return out;
|
|
135531
|
-
}
|
|
135532
|
-
const LOADING_STAGES = [
|
|
135533
|
-
"正在整理记忆区域....",
|
|
135534
|
-
"正在加载用户喜好....",
|
|
135535
|
-
"正在确认模型配置....",
|
|
135536
|
-
"正在加载scream code...."
|
|
135537
|
-
];
|
|
135538
|
-
const STAGE_DELAYS_MS = [
|
|
135539
|
-
450,
|
|
135540
|
-
350,
|
|
135541
|
-
650,
|
|
135542
|
-
350
|
|
135543
|
-
];
|
|
135544
135542
|
function runLoadingAnimation(theme = "dark") {
|
|
135545
|
-
const green = THEME_GREEN[theme];
|
|
135546
135543
|
if (!supportsAnsi()) {
|
|
135547
|
-
stdout.write(
|
|
135548
|
-
for (const stage of LOADING_STAGES) stdout.write(green + stage + "\x1B[0m\n");
|
|
135544
|
+
for (const line of LOGO) stdout.write(`${fg(...LOGO_RGB)}${line}${RESET}\n`);
|
|
135549
135545
|
return Promise.resolve();
|
|
135550
135546
|
}
|
|
135551
135547
|
return new Promise((resolve) => {
|
|
135552
|
-
|
|
135553
|
-
|
|
135554
|
-
|
|
135555
|
-
|
|
135556
|
-
|
|
135557
|
-
|
|
135558
|
-
|
|
135559
|
-
|
|
135560
|
-
|
|
135561
|
-
|
|
135562
|
-
|
|
135563
|
-
|
|
135564
|
-
|
|
135565
|
-
|
|
135566
|
-
const
|
|
135567
|
-
|
|
135548
|
+
stdout.write("\x1B[?1049h");
|
|
135549
|
+
stdout.write("\x1B[2J");
|
|
135550
|
+
stdout.write("\x1B[?25l");
|
|
135551
|
+
const accent = THEME_ACCENT[theme];
|
|
135552
|
+
let sheenPos = 0;
|
|
135553
|
+
let isReversing = false;
|
|
135554
|
+
let shimmerPulse = 0;
|
|
135555
|
+
let phase = "loading";
|
|
135556
|
+
function render() {
|
|
135557
|
+
const { cols, rows } = getTerminalSize();
|
|
135558
|
+
const lines = [];
|
|
135559
|
+
const contentHeight = LOGO.length + 4;
|
|
135560
|
+
const topPad = Math.max(0, Math.floor((rows - contentHeight) / 2));
|
|
135561
|
+
for (let i = 0; i < topPad; i++) lines.push("");
|
|
135562
|
+
for (const line of LOGO) {
|
|
135563
|
+
let colored = "";
|
|
135564
|
+
for (let ci = 0; ci < line.length; ci++) colored += renderSheen(line[ci], ci, sheenPos, isReversing, accent);
|
|
135565
|
+
lines.push(centerPad(colored, cols));
|
|
135566
|
+
}
|
|
135567
|
+
if (phase === "loading") lines.push(centerPad(renderShimmer(shimmerPulse, accent), cols));
|
|
135568
|
+
else lines.push(centerPad(`${BOLD}${fg(...accent)}点击 ENTER 进入${RESET}`, cols));
|
|
135569
|
+
lines.push("");
|
|
135570
|
+
lines.push("");
|
|
135571
|
+
lines.push(centerPad(`${fg(...DIM_RGB)}按 Ctrl+C 即可退出Scream Code${RESET}`, cols));
|
|
135572
|
+
while (lines.length < rows) lines.push("");
|
|
135573
|
+
stdout.write("\x1B[H");
|
|
135574
|
+
stdout.write(lines.join("\n"));
|
|
135568
135575
|
}
|
|
135569
135576
|
function tick() {
|
|
135570
|
-
|
|
135571
|
-
|
|
135572
|
-
|
|
135573
|
-
|
|
135574
|
-
return;
|
|
135577
|
+
sheenPos += SHEEN_STEP;
|
|
135578
|
+
if (sheenPos >= 90) {
|
|
135579
|
+
isReversing = !isReversing;
|
|
135580
|
+
sheenPos = 0;
|
|
135575
135581
|
}
|
|
135576
|
-
|
|
135577
|
-
|
|
135578
|
-
|
|
135582
|
+
shimmerPulse = (shimmerPulse + 1) % 6;
|
|
135583
|
+
render();
|
|
135584
|
+
}
|
|
135585
|
+
function cleanup() {
|
|
135586
|
+
clearInterval(timer);
|
|
135587
|
+
stdin.removeAllListeners("data");
|
|
135588
|
+
stdin.setRawMode(false);
|
|
135589
|
+
stdout.write("\x1B[?25h");
|
|
135590
|
+
stdout.write("\x1B[?1049l");
|
|
135579
135591
|
}
|
|
135580
|
-
|
|
135581
|
-
|
|
135582
|
-
|
|
135592
|
+
function interrupt() {
|
|
135593
|
+
cleanup();
|
|
135594
|
+
process$1.exit(0);
|
|
135595
|
+
}
|
|
135596
|
+
process$1.on("SIGINT", interrupt);
|
|
135597
|
+
process$1.on("SIGTERM", interrupt);
|
|
135598
|
+
stdin.setRawMode(true);
|
|
135599
|
+
stdin.on("data", (data) => {
|
|
135600
|
+
const key = data.toString();
|
|
135601
|
+
if ((key === "\r" || key === "\n") && phase === "ready") {
|
|
135602
|
+
cleanup();
|
|
135603
|
+
resolve();
|
|
135604
|
+
}
|
|
135605
|
+
});
|
|
135606
|
+
render();
|
|
135607
|
+
const timer = setInterval(tick, SHEEN_INTERVAL_MS);
|
|
135608
|
+
setTimeout(() => {
|
|
135609
|
+
phase = "ready";
|
|
135610
|
+
render();
|
|
135611
|
+
}, 400);
|
|
135583
135612
|
});
|
|
135584
135613
|
}
|
|
135585
135614
|
//#endregion
|