@saturn-universe/cli 0.1.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/auth-config.js +56 -18
- 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/menu.d.ts +1 -1
- package/dist/menu.js +2 -2
- package/dist/provider-discovery.d.ts +7 -1
- package/dist/provider-discovery.js +120 -12
- package/dist/provider-pricing.d.ts +1 -1
- package/dist/provider-pricing.js +7 -3
- package/dist/provider-wizard.d.ts +18 -0
- package/dist/provider-wizard.js +109 -0
- package/dist/provider.js +114 -37
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.js +6 -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
|
@@ -10,8 +10,10 @@ interface HistoryOutput {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function messageEntryKey(messageId: string): string;
|
|
12
12
|
export declare function historyEntryKey(message: SessionHistoryMessage): string;
|
|
13
|
-
export declare function createSessionHistoryLoader(workdir: string, route: HistoryRoute, output: HistoryOutput): {
|
|
13
|
+
export declare function createSessionHistoryLoader(workdir: string, route: HistoryRoute, output: HistoryOutput, firstPageLimit?: number): {
|
|
14
14
|
load(): Promise<void>;
|
|
15
|
-
|
|
15
|
+
pause(): void;
|
|
16
|
+
resume: () => void;
|
|
17
|
+
close(): void;
|
|
16
18
|
};
|
|
17
19
|
export {};
|
package/dist/session-history.js
CHANGED
|
@@ -11,13 +11,15 @@ export function historyEntryKey(message) {
|
|
|
11
11
|
return `tool:${message.runId}:${message.toolCallId}`;
|
|
12
12
|
return messageEntryKey(message.id);
|
|
13
13
|
}
|
|
14
|
-
export function createSessionHistoryLoader(workdir, route, output) {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export function createSessionHistoryLoader(workdir, route, output, firstPageLimit = MAX_SESSION_HISTORY_PAGE_SIZE) {
|
|
15
|
+
let controller = new AbortController();
|
|
16
|
+
let closed = false;
|
|
17
|
+
let paused;
|
|
18
|
+
let resume;
|
|
17
19
|
// An undefined boundary starts at the snapshot head. A null boundary marks a completed history.
|
|
18
20
|
let cursor;
|
|
19
21
|
let pending;
|
|
20
|
-
async function completeMessage(message) {
|
|
22
|
+
async function completeMessage(message, signal) {
|
|
21
23
|
let text = message.text;
|
|
22
24
|
let offset = message.nextOffset;
|
|
23
25
|
while (offset !== undefined) {
|
|
@@ -33,12 +35,12 @@ export function createSessionHistoryLoader(workdir, route, output) {
|
|
|
33
35
|
}
|
|
34
36
|
return text;
|
|
35
37
|
}
|
|
36
|
-
async function readPage() {
|
|
38
|
+
async function readPage(signal) {
|
|
37
39
|
try {
|
|
38
40
|
const page = await sendHostCommand(workdir, {
|
|
39
41
|
type: 'session.history',
|
|
40
42
|
...route,
|
|
41
|
-
limit: MAX_SESSION_HISTORY_PAGE_SIZE,
|
|
43
|
+
limit: cursor?.before ? MAX_SESSION_HISTORY_PAGE_SIZE : firstPageLimit,
|
|
42
44
|
...(cursor ? { through: cursor.through } : {}),
|
|
43
45
|
...(cursor?.before ? { before: cursor.before } : {}),
|
|
44
46
|
}, { signal });
|
|
@@ -49,7 +51,7 @@ export function createSessionHistoryLoader(workdir, route, output) {
|
|
|
49
51
|
for (const message of page.messages) {
|
|
50
52
|
if (message.nextOffset === undefined)
|
|
51
53
|
continue;
|
|
52
|
-
const text = await completeMessage(message);
|
|
54
|
+
const text = await completeMessage(message, signal);
|
|
53
55
|
if (signal.aborted)
|
|
54
56
|
return;
|
|
55
57
|
output.onMessage(message, text);
|
|
@@ -62,15 +64,45 @@ export function createSessionHistoryLoader(workdir, route, output) {
|
|
|
62
64
|
output.onError(error);
|
|
63
65
|
}
|
|
64
66
|
}
|
|
67
|
+
// Retry only the interrupted page, at the same snapshot and pagination boundary.
|
|
68
|
+
async function loadPage() {
|
|
69
|
+
while (!closed) {
|
|
70
|
+
if (paused) {
|
|
71
|
+
await paused;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const { signal } = controller;
|
|
75
|
+
await readPage(signal);
|
|
76
|
+
if (!signal.aborted)
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function resumeLoading() {
|
|
81
|
+
paused = undefined;
|
|
82
|
+
resume?.();
|
|
83
|
+
resume = undefined;
|
|
84
|
+
}
|
|
65
85
|
return {
|
|
66
86
|
load() {
|
|
67
|
-
if (
|
|
87
|
+
if (closed || cursor?.before === null)
|
|
68
88
|
return Promise.resolve();
|
|
69
|
-
pending ??=
|
|
89
|
+
pending ??= loadPage().finally(() => {
|
|
70
90
|
pending = undefined;
|
|
71
91
|
});
|
|
72
92
|
return pending;
|
|
73
93
|
},
|
|
74
|
-
|
|
94
|
+
pause() {
|
|
95
|
+
if (closed || paused)
|
|
96
|
+
return;
|
|
97
|
+
paused = new Promise((resolve) => (resume = resolve));
|
|
98
|
+
controller.abort();
|
|
99
|
+
controller = new AbortController();
|
|
100
|
+
},
|
|
101
|
+
resume: resumeLoading,
|
|
102
|
+
close() {
|
|
103
|
+
closed = true;
|
|
104
|
+
controller.abort();
|
|
105
|
+
resumeLoading();
|
|
106
|
+
},
|
|
75
107
|
};
|
|
76
108
|
}
|
package/dist/slash-commands.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface ReplHooks {
|
|
|
53
53
|
restartHost?(): Promise<HostStatusSnapshot>;
|
|
54
54
|
promptMcpSecret?(label: string): Promise<string | null>;
|
|
55
55
|
persistDefaults?(patch: UserConfigDefaultsPatch): Promise<SaveUserConfigResult>;
|
|
56
|
+
getLiveMemberSession?(sessionId: string): SessionSummary | undefined;
|
|
56
57
|
onSessionChanged?(info: SessionSummary): void;
|
|
57
58
|
checkSessionSwitch?(info: SessionSummary): void;
|
|
58
59
|
getNavigationSignal?(): AbortSignal | undefined;
|
package/dist/slash-commands.js
CHANGED
|
@@ -7,7 +7,7 @@ import { compactionArguments, compactionOptions, compactionOptionUsage } from '.
|
|
|
7
7
|
import { ensureHostWorkspace, reconcileRunTool, resolveRunApproval, sendHostCommand, } from './host-command.js';
|
|
8
8
|
import { stopHost } from './host-launcher.js';
|
|
9
9
|
import { reconciliationCommand, reconciliationOptions } from './reconcile-command.js';
|
|
10
|
-
import { applyReplMode } from './repl-host.js';
|
|
10
|
+
import { applyReplMode, applyReplSessionMode } from './repl-host.js';
|
|
11
11
|
import { renderConfigCheck, renderConfigInit, renderConfigSummary, renderReplHelp, renderShortcutHelp, renderTeamBoard, renderUsageCard, } from './renderer.js';
|
|
12
12
|
import { initUserConfig, inspectUserConfig, syncUserConfigDefaults, } from './user-config.js';
|
|
13
13
|
import { authenticateMcpServer, formatMcpServerStatus, listMcpServersInfo, setWorkspaceMcpTrust, } from './mcp-cli.js';
|
|
@@ -364,6 +364,7 @@ export async function ensureWorkspaceId(state) {
|
|
|
364
364
|
function selectSession(state, hooks, sessionId, summary) {
|
|
365
365
|
state.sessionId = sessionId;
|
|
366
366
|
state.member = summary.member;
|
|
367
|
+
applyReplSessionMode(state, summary.modeRef);
|
|
367
368
|
state.lastRunId = summary.latestRun?.id;
|
|
368
369
|
state.hasRunHistory = (summary.runCount ?? 0) > 0 || state.lastRunId !== undefined;
|
|
369
370
|
hooks.onSessionChanged?.({ ...summary, id: sessionId });
|
|
@@ -371,7 +372,8 @@ function selectSession(state, hooks, sessionId, summary) {
|
|
|
371
372
|
async function switchSession(state, hooks, sessionId, signal) {
|
|
372
373
|
if (signal?.aborted)
|
|
373
374
|
return;
|
|
374
|
-
const
|
|
375
|
+
const live = hooks.getLiveMemberSession?.(sessionId);
|
|
376
|
+
const session = live ?? (await sendHostCommand(state.workdir, { type: 'session.query', sessionId }, { signal }));
|
|
375
377
|
if (signal?.aborted)
|
|
376
378
|
return;
|
|
377
379
|
hooks.checkSessionSwitch?.(session);
|
|
@@ -1158,6 +1160,18 @@ export async function handleSlashCommand(line, state, hooks) {
|
|
|
1158
1160
|
if (hooks.isRunActive?.()) {
|
|
1159
1161
|
throw new Error('当前有正在执行的任务,请等待完成或先 /cancel 后再切换 Mode');
|
|
1160
1162
|
}
|
|
1163
|
+
if (state.sessionId) {
|
|
1164
|
+
await hooks.ensureConnected();
|
|
1165
|
+
const { mode } = await sendHostCommand(state.workdir, {
|
|
1166
|
+
type: 'session.mode.select',
|
|
1167
|
+
sessionId: state.member?.parentSessionId ?? state.sessionId,
|
|
1168
|
+
modeRef: normalizedInput,
|
|
1169
|
+
});
|
|
1170
|
+
state.sessionModeRef = mode.ref;
|
|
1171
|
+
applyReplMode(state, mode);
|
|
1172
|
+
hooks.writeLine('已切换当前会话的 Mode 为 ' + mode.displayName + ' (' + mode.ref + ')');
|
|
1173
|
+
return 'continue';
|
|
1174
|
+
}
|
|
1161
1175
|
if (state.lastRunId) {
|
|
1162
1176
|
try {
|
|
1163
1177
|
const run = await sendHostCommand(state.workdir, {
|
package/dist/terminal-text.js
CHANGED
|
@@ -2,6 +2,8 @@ const ANSI_ESCAPE = /\x1b(?:\[[0-9;?]*[A-Za-z]|\][^\x07]*?(?:\x07|\x1b\\))/g;
|
|
|
2
2
|
const graphemes = new Intl.Segmenter();
|
|
3
3
|
const emojiPresentation = new RegExp('^\\p{RGI_Emoji}$', 'v');
|
|
4
4
|
const printableAscii = /^[\x20-\x7e]*$/;
|
|
5
|
+
// These terminal cells cannot form combining or emoji sequences.
|
|
6
|
+
const simpleCells = /^[\x20-\x7e\u00b7\u2500-\u259f\u4e00-\u9fff]*$/;
|
|
5
7
|
const SGR_RESET = '\x1b[0m';
|
|
6
8
|
export function terminalColorEnabled(override) {
|
|
7
9
|
if (override !== undefined)
|
|
@@ -101,6 +103,13 @@ export function stringDisplayWidth(text) {
|
|
|
101
103
|
const visible = stripAnsi(text);
|
|
102
104
|
if (printableAscii.test(visible))
|
|
103
105
|
return visible.length;
|
|
106
|
+
if (simpleCells.test(visible)) {
|
|
107
|
+
let width = visible.length;
|
|
108
|
+
for (let i = 0; i < visible.length; i++)
|
|
109
|
+
if (visible.charCodeAt(i) >= 0x4e00)
|
|
110
|
+
width++;
|
|
111
|
+
return width;
|
|
112
|
+
}
|
|
104
113
|
let width = 0;
|
|
105
114
|
for (const grapheme of displayGraphemes(visible))
|
|
106
115
|
width += grapheme.width;
|
|
@@ -134,6 +143,8 @@ function* displayTokens(text) {
|
|
|
134
143
|
export function truncateDisplay(text, maxWidth) {
|
|
135
144
|
if (maxWidth <= 0)
|
|
136
145
|
return '';
|
|
146
|
+
if (printableAscii.test(text))
|
|
147
|
+
return text.slice(0, maxWidth);
|
|
137
148
|
let width = 0;
|
|
138
149
|
let end = 0;
|
|
139
150
|
let hasAnsi = false;
|
|
@@ -207,14 +218,29 @@ export function* wrapDisplayRanges(text, maxWidth) {
|
|
|
207
218
|
let start = paragraphStart;
|
|
208
219
|
let end = paragraphStart;
|
|
209
220
|
let lineWidth = 0;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
lineWidth
|
|
221
|
+
if (simpleCells.test(paragraph)) {
|
|
222
|
+
// Each code unit is one complete grapheme here. Only the CJK range occupies two cells.
|
|
223
|
+
for (let i = 0; i < paragraph.length; i++) {
|
|
224
|
+
const width = paragraph.charCodeAt(i) >= 0x4e00 ? 2 : 1;
|
|
225
|
+
if (lineWidth > 0 && lineWidth + width > limit) {
|
|
226
|
+
yield { start, end, soft: start !== paragraphStart };
|
|
227
|
+
start = end;
|
|
228
|
+
lineWidth = 0;
|
|
229
|
+
}
|
|
230
|
+
end++;
|
|
231
|
+
lineWidth += width;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
for (const { end: tokenEnd, width } of displayTokens(paragraph)) {
|
|
236
|
+
if (lineWidth > 0 && width > 0 && lineWidth + width > limit) {
|
|
237
|
+
yield { start, end, soft: start !== paragraphStart };
|
|
238
|
+
start = end;
|
|
239
|
+
lineWidth = 0;
|
|
240
|
+
}
|
|
241
|
+
end = paragraphStart + tokenEnd;
|
|
242
|
+
lineWidth += width;
|
|
215
243
|
}
|
|
216
|
-
end = paragraphStart + tokenEnd;
|
|
217
|
-
lineWidth += width;
|
|
218
244
|
}
|
|
219
245
|
yield { start, end, soft: start !== paragraphStart };
|
|
220
246
|
paragraphStart = end + 1;
|
package/dist/tui.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export interface OrbitalViewModel extends SlashCommandContext {
|
|
|
88
88
|
readonly maskLength: number;
|
|
89
89
|
} | undefined;
|
|
90
90
|
readonly statusHint?: string | undefined;
|
|
91
|
+
readonly pendingSatellite?: string | undefined;
|
|
91
92
|
readonly color?: boolean | undefined;
|
|
92
93
|
}
|
|
93
94
|
export type ResumeSessionChoice = Pick<SessionListItem, 'id' | 'title' | 'status' | 'updatedAt' | 'modeRef' | 'firstUserMessage' | 'runCount' | 'latestRunStatus'>;
|
|
@@ -145,6 +146,7 @@ export interface OrbitalTui {
|
|
|
145
146
|
rekeyEntry(from: string, to: string): void;
|
|
146
147
|
removeEntry(key: string): void;
|
|
147
148
|
clearEntries(): void;
|
|
149
|
+
showHistoryPreview(entries: readonly OrbitalEntry[]): void;
|
|
148
150
|
prependHistory(entries: readonly (OrbitalEntry & {
|
|
149
151
|
readonly key: string;
|
|
150
152
|
})[]): void;
|
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.
|
|
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",
|