@saturn-universe/cli 0.1.2-dev.1 → 0.1.2-dev.10
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/attach.d.ts +3 -1
- package/dist/attach.js +4 -1
- package/dist/cli-help.js +1 -1
- package/dist/config-cli.js +16 -4
- package/dist/host-launcher.d.ts +2 -1
- package/dist/host-launcher.js +16 -1
- package/dist/provider-discovery.d.ts +1 -0
- package/dist/provider-discovery.js +2 -1
- package/dist/provider-pricing.d.ts +1 -1
- package/dist/provider-pricing.js +3 -2
- package/dist/provider-wizard.d.ts +18 -0
- package/dist/provider-wizard.js +109 -0
- package/dist/provider.js +95 -37
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.js +5 -3
- package/dist/repl-host.d.ts +2 -0
- package/dist/repl-host.js +9 -1
- package/dist/repl-run-observer.js +1 -0
- package/dist/repl.js +118 -23
- package/dist/session-history.d.ts +4 -2
- package/dist/session-history.js +42 -10
- package/dist/slash-commands.d.ts +1 -0
- package/dist/slash-commands.js +16 -2
- package/dist/terminal-text.js +33 -7
- package/dist/tui.d.ts +2 -0
- package/dist/tui.js +87 -42
- package/package.json +4 -3
package/dist/tui.js
CHANGED
|
@@ -87,7 +87,8 @@ function satelliteTree(satellites) {
|
|
|
87
87
|
const SPINNER_FRAMES = ['◐', '◓', '◑', '◒'];
|
|
88
88
|
const THINKING_SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
89
89
|
function fitCell(text, width) {
|
|
90
|
-
|
|
90
|
+
const used = stringDisplayWidth(text);
|
|
91
|
+
return used <= width ? text + ' '.repeat(width - used) : padEndDisplay(truncateDisplay(text, width), width);
|
|
91
92
|
}
|
|
92
93
|
function renderDockMetadata(model, cols, p) {
|
|
93
94
|
const isMain = (model.teamMember ?? 'main') === 'main';
|
|
@@ -459,7 +460,7 @@ function renderSidebarLines(model, tree, width, height, p, colStart) {
|
|
|
459
460
|
? rootStatus
|
|
460
461
|
: truncateDisplay(terminalText(label).replace(/\s+/g, ' '), inner - 8);
|
|
461
462
|
const statusWidth = stringDisplayWidth(status);
|
|
462
|
-
const indent = isFocusedItem && !p.colored ? '▸' : ' ';
|
|
463
|
+
const indent = sat.id === model.pendingSatellite || (isFocusedItem && !p.colored) ? '▸' : ' ';
|
|
463
464
|
const prefix = `${indent}${branch ? p.dim(branch.trimEnd()) + ' ' : ''}${isRoot ? p.gold('◎') : glyph} `;
|
|
464
465
|
const contentWidth = width - statusWidth - 2;
|
|
465
466
|
const id = truncateDisplay(terminalText(sat.id).replace(/\s+/g, ' '), contentWidth - stringDisplayWidth(prefix));
|
|
@@ -778,7 +779,67 @@ function formatToolSummaryLines(plain, maxWidth, p, soft) {
|
|
|
778
779
|
}
|
|
779
780
|
return out;
|
|
780
781
|
}
|
|
782
|
+
const thinkingPreviewRows = 5;
|
|
783
|
+
const thinkingLayouts = new WeakMap();
|
|
784
|
+
function thinkingLayout(entry, width, expanded) {
|
|
785
|
+
const cached = thinkingLayouts.get(entry);
|
|
786
|
+
if (cached?.width === width && cached.expanded === expanded)
|
|
787
|
+
return cached;
|
|
788
|
+
let text = terminalText(entry.text);
|
|
789
|
+
let clipped = false;
|
|
790
|
+
if (entry.streaming && !expanded) {
|
|
791
|
+
// Keep one overflow row. Also bound a single newline-free paragraph, allowing room
|
|
792
|
+
// for multi-unit graphemes. Expansion always uses the original text.
|
|
793
|
+
let end = text.length;
|
|
794
|
+
for (let row = 0; row <= thinkingPreviewRows && end > 0; row++) {
|
|
795
|
+
end = text.lastIndexOf('\n', end - 1);
|
|
796
|
+
if (end < 0)
|
|
797
|
+
break;
|
|
798
|
+
if (row === thinkingPreviewRows) {
|
|
799
|
+
text = text.slice(end + 1);
|
|
800
|
+
clipped = true;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
const budget = (thinkingPreviewRows + 1) * width * 4;
|
|
804
|
+
const cut = Math.floor((text.length - budget) / width) * width;
|
|
805
|
+
if (cut > 0) {
|
|
806
|
+
const segment = segmentGraphemes(text).containing(cut);
|
|
807
|
+
text = text.slice(segment.index);
|
|
808
|
+
clipped ||= segment.index > 0;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
const wraps = new Set();
|
|
812
|
+
const lines = wrapTextByWidth(text, width, wraps);
|
|
813
|
+
const collapsed = !expanded && (clipped || lines.length > thinkingPreviewRows);
|
|
814
|
+
const visible = thinkingPreviewRows - 1;
|
|
815
|
+
const start = collapsed && entry.streaming ? Math.max(0, lines.length - visible) : 0;
|
|
816
|
+
const body = collapsed ? lines.slice(start, start + visible) : lines;
|
|
817
|
+
const soft = [...wraps]
|
|
818
|
+
.filter((row) => row >= start && row < start + body.length)
|
|
819
|
+
.map((row) => row - start + (collapsed && entry.streaming ? 2 : 1));
|
|
820
|
+
const fold = clipped ? '较早内容' : `+${lines.length - body.length} 行`;
|
|
821
|
+
const layout = { width, expanded, body, soft, ...(collapsed ? { fold } : {}) };
|
|
822
|
+
thinkingLayouts.set(entry, layout);
|
|
823
|
+
return layout;
|
|
824
|
+
}
|
|
781
825
|
function formatEntryLines(entry, leftWidth, p, soft, showDetails = false, spinnerFrame = 0) {
|
|
826
|
+
if (entry.kind === 'thinking') {
|
|
827
|
+
const layout = thinkingLayout(entry, Math.max(4, leftWidth - 2), showDetails);
|
|
828
|
+
for (const row of layout.soft)
|
|
829
|
+
soft.add(row);
|
|
830
|
+
const header = entry.streaming
|
|
831
|
+
? `${THINKING_SPINNER[Math.max(0, Math.floor(spinnerFrame)) % THINKING_SPINNER.length]} Thinking…`
|
|
832
|
+
: '✦ Thinking';
|
|
833
|
+
const body = layout.body.map((line) => `${p.dim('│ ')}${p.thinkingItalic(line)}`);
|
|
834
|
+
if (layout.fold) {
|
|
835
|
+
const fold = p.dim(`│ … ${layout.fold} · Ctrl+O 展开`);
|
|
836
|
+
if (entry.streaming)
|
|
837
|
+
body.unshift(fold);
|
|
838
|
+
else
|
|
839
|
+
body.push(fold);
|
|
840
|
+
}
|
|
841
|
+
return [p.magenta(header), ...body];
|
|
842
|
+
}
|
|
782
843
|
const plain = terminalText(entry.text);
|
|
783
844
|
const out = [];
|
|
784
845
|
switch (entry.kind) {
|
|
@@ -806,40 +867,6 @@ function formatEntryLines(entry, leftWidth, p, soft, showDetails = false, spinne
|
|
|
806
867
|
markdownLayouts.set(entry, { width: leftWidth, colored: p.colored, lines, soft });
|
|
807
868
|
return lines;
|
|
808
869
|
}
|
|
809
|
-
case 'thinking': {
|
|
810
|
-
const frame = Math.max(0, Math.floor(spinnerFrame));
|
|
811
|
-
const wraps = new Set();
|
|
812
|
-
const lines = wrapTextByWidth(plain, Math.max(4, leftWidth - 2), wraps);
|
|
813
|
-
const bodyLine = (line) => `${p.dim('│ ')}${p.thinkingItalic(line)}`;
|
|
814
|
-
const collapseLine = (omitted) => p.dim(`│ … +${omitted} 行 · Ctrl+O 展开`);
|
|
815
|
-
if (entry.streaming) {
|
|
816
|
-
const header = p.magenta(`${THINKING_SPINNER[frame % THINKING_SPINNER.length]} Thinking…`);
|
|
817
|
-
if (!showDetails && lines.length > 5) {
|
|
818
|
-
const tailCount = 4;
|
|
819
|
-
const omitted = lines.length - tailCount;
|
|
820
|
-
const tail = lines.slice(-tailCount);
|
|
821
|
-
const offset = lines.length - tail.length;
|
|
822
|
-
for (const index of wraps)
|
|
823
|
-
if (index >= offset)
|
|
824
|
-
soft.add(index - offset + 2);
|
|
825
|
-
return [header, collapseLine(omitted), ...tail.map(bodyLine)];
|
|
826
|
-
}
|
|
827
|
-
for (const index of wraps)
|
|
828
|
-
soft.add(index + 1);
|
|
829
|
-
return [header, ...lines.map(bodyLine)];
|
|
830
|
-
}
|
|
831
|
-
const header = p.magenta('✦ Thinking');
|
|
832
|
-
const collapsed = !showDetails && lines.length > 5;
|
|
833
|
-
const visible = collapsed ? lines.slice(0, 4) : lines;
|
|
834
|
-
for (const index of wraps)
|
|
835
|
-
if (index < visible.length)
|
|
836
|
-
soft.add(index + 1);
|
|
837
|
-
return [
|
|
838
|
-
header,
|
|
839
|
-
...visible.map(bodyLine),
|
|
840
|
-
...(collapsed ? [collapseLine(lines.length - visible.length)] : []),
|
|
841
|
-
];
|
|
842
|
-
}
|
|
843
870
|
case 'planner': {
|
|
844
871
|
const text = plain.startsWith('[Planner]') ? plain : `[Planner] ${plain}`;
|
|
845
872
|
const wrapped = wrapTextByWidth(text, Math.max(4, leftWidth - 2), soft);
|
|
@@ -1289,7 +1316,7 @@ export function renderOrbitalFrame(model, cols, rows, anchor) {
|
|
|
1289
1316
|
bodyRows.push(leftCell);
|
|
1290
1317
|
}
|
|
1291
1318
|
}
|
|
1292
|
-
const allLines = [...bodyRows, ...dock.lines
|
|
1319
|
+
const allLines = [...bodyRows, ...dock.lines.map((line) => fitCell(line, safeCols))];
|
|
1293
1320
|
const cursorRow = Math.max(0, Math.min(safeRows - 1, bodyHeight + dock.cursorInputRowOffset));
|
|
1294
1321
|
const cursorCol = Math.max(0, Math.min(safeCols - 1, dock.cursorCol));
|
|
1295
1322
|
return {
|
|
@@ -1327,6 +1354,7 @@ export function createOrbitalTui(options) {
|
|
|
1327
1354
|
const hints = options.hints;
|
|
1328
1355
|
let telemetry = { ...options.initialModel };
|
|
1329
1356
|
const entries = [];
|
|
1357
|
+
let historyPreview = [];
|
|
1330
1358
|
let scrollOffset = 0;
|
|
1331
1359
|
let scrollAnchor;
|
|
1332
1360
|
let viewport;
|
|
@@ -1379,10 +1407,12 @@ export function createOrbitalTui(options) {
|
|
|
1379
1407
|
const getPaletteState = () => paletteDismissed ? undefined : resolvePaletteState(buffer, hints, telemetry);
|
|
1380
1408
|
const buildViewModel = () => {
|
|
1381
1409
|
const prompts = submissionQueue.filter(isPrompt);
|
|
1410
|
+
const showPreview = historyPreview.length > 0 && entries.every((entry) => entry.kind === 'system');
|
|
1382
1411
|
return {
|
|
1383
1412
|
...telemetry,
|
|
1384
1413
|
spinnerFrame,
|
|
1385
|
-
entries,
|
|
1414
|
+
entries: showPreview ? [...historyPreview, ...entries] : entries,
|
|
1415
|
+
...(showPreview && !telemetry.statusHint ? { statusHint: '正在加载最新历史…' } : {}),
|
|
1386
1416
|
scrollOffset,
|
|
1387
1417
|
showDetails,
|
|
1388
1418
|
focusArea,
|
|
@@ -1430,7 +1460,7 @@ export function createOrbitalTui(options) {
|
|
|
1430
1460
|
scrollOffset = viewport.offset;
|
|
1431
1461
|
scrollAnchor = viewport.anchor;
|
|
1432
1462
|
}
|
|
1433
|
-
const body = frame.lines.map((line, i) => `\x1b[${i + 1};1H${
|
|
1463
|
+
const body = frame.lines.map((line, i) => `\x1b[${i + 1};1H${line}`).join('');
|
|
1434
1464
|
let overlay = '';
|
|
1435
1465
|
if (selection &&
|
|
1436
1466
|
!(selection.start.x === selection.end.x && selection.start.absRow === selection.end.absRow)) {
|
|
@@ -1651,8 +1681,8 @@ export function createOrbitalTui(options) {
|
|
|
1651
1681
|
if (hit) {
|
|
1652
1682
|
selection = undefined;
|
|
1653
1683
|
focusedSatelliteId = hit.memberId;
|
|
1654
|
-
renderNow();
|
|
1655
1684
|
selectSatelliteHandler?.(hit.memberId);
|
|
1685
|
+
queueRender();
|
|
1656
1686
|
return;
|
|
1657
1687
|
}
|
|
1658
1688
|
if (lastFrame &&
|
|
@@ -1820,6 +1850,8 @@ export function createOrbitalTui(options) {
|
|
|
1820
1850
|
}
|
|
1821
1851
|
};
|
|
1822
1852
|
function closeSideQuestion() {
|
|
1853
|
+
if (!sideRequest && !sideQuestion)
|
|
1854
|
+
return;
|
|
1823
1855
|
sideRequest?.abort();
|
|
1824
1856
|
sideRequest = undefined;
|
|
1825
1857
|
sideQuestion = undefined;
|
|
@@ -2107,7 +2139,7 @@ export function createOrbitalTui(options) {
|
|
|
2107
2139
|
focusArea = 'composer';
|
|
2108
2140
|
if (selected)
|
|
2109
2141
|
selectSatelliteHandler?.(selected);
|
|
2110
|
-
|
|
2142
|
+
queueRender();
|
|
2111
2143
|
return;
|
|
2112
2144
|
}
|
|
2113
2145
|
return;
|
|
@@ -2430,7 +2462,19 @@ export function createOrbitalTui(options) {
|
|
|
2430
2462
|
entries[index] = { ...entries[index], key: to };
|
|
2431
2463
|
queueRender();
|
|
2432
2464
|
},
|
|
2465
|
+
showHistoryPreview(preview) {
|
|
2466
|
+
historyPreview = preview;
|
|
2467
|
+
queueRender();
|
|
2468
|
+
},
|
|
2433
2469
|
prependHistory(history) {
|
|
2470
|
+
if (historyPreview.length) {
|
|
2471
|
+
historyPreview = [];
|
|
2472
|
+
clearDragScroll();
|
|
2473
|
+
selection = undefined;
|
|
2474
|
+
scrollAnchor = undefined;
|
|
2475
|
+
scrollOffset = 0;
|
|
2476
|
+
queueRender();
|
|
2477
|
+
}
|
|
2434
2478
|
const existing = new Set(entries.map((entry) => entry.key));
|
|
2435
2479
|
const older = history.filter((entry) => !existing.has(entry.key));
|
|
2436
2480
|
if (!older.length)
|
|
@@ -2449,9 +2493,10 @@ export function createOrbitalTui(options) {
|
|
|
2449
2493
|
clearDragScroll();
|
|
2450
2494
|
selection = undefined;
|
|
2451
2495
|
entries.length = 0;
|
|
2496
|
+
historyPreview = [];
|
|
2452
2497
|
scrollOffset = 0;
|
|
2453
2498
|
scrollAnchor = undefined;
|
|
2454
|
-
|
|
2499
|
+
queueRender();
|
|
2455
2500
|
},
|
|
2456
2501
|
updateTelemetry(patch) {
|
|
2457
2502
|
telemetry = { ...telemetry, ...patch };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saturn-universe/cli",
|
|
3
|
-
"version": "0.1.2-dev.
|
|
3
|
+
"version": "0.1.2-dev.10",
|
|
4
4
|
"description": "Saturn local multi-agent runtime CLI",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@
|
|
12
|
-
"@saturn-universe/
|
|
11
|
+
"@clack/prompts": "1.9.0",
|
|
12
|
+
"@saturn-universe/protocol": "0.1.2-dev.10",
|
|
13
|
+
"@saturn-universe/runtime-host": "0.1.2-dev.10",
|
|
13
14
|
"mdast-util-from-markdown": "^2.1.0",
|
|
14
15
|
"mdast-util-gfm": "^3.1.0",
|
|
15
16
|
"micromark-extension-gfm": "^3.0.0",
|