@tiens.nguyen/gu-cli 1.0.931 → 1.0.935
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/autocompact.mjs +136 -0
- package/browser-bridge.mjs +8 -0
- package/browser-extension/README.md +4 -0
- package/browser-extension/actions.js +366 -5
- package/browser-extension/background.js +104 -14
- package/browser-extension/manifest.json +1 -1
- package/browser-extension/popup.html +83 -15
- package/browser-extension/popup.js +145 -35
- package/clear-state.mjs +12 -1
- package/cli-token.mjs +6 -3
- package/client-expert-api.mjs +109 -20
- package/client-expert-run.mjs +263 -120
- package/client-expert-setup.mjs +3 -2
- package/coding-provider-setup.mjs +27 -0
- package/free-model.mjs +33 -6
- package/gonext_agent_chat.py +748 -27
- package/gu-cli.mjs +90 -6
- package/gu-repl.mjs +545 -29
- package/gu_browser.py +83 -9
- package/gu_gif.py +101 -0
- package/gu_turn_notes.py +29 -2
- package/install-path.mjs +52 -20
- package/lsp-client.mjs +267 -0
- package/lsp-host.mjs +391 -0
- package/lsp-registry.mjs +568 -0
- package/model-doctor.mjs +34 -7
- package/model-prices.mjs +22 -0
- package/next-suggestion.mjs +137 -0
- package/package.json +10 -1
- package/powershell-alias.mjs +12 -1
- package/python-unix.mjs +120 -0
- package/setup-fixes.mjs +245 -0
- package/step-group.mjs +59 -18
- package/terminal-layout.mjs +82 -3
- package/turn-notes.mjs +65 -0
- package/win-shell.mjs +26 -0
package/gu-repl.mjs
CHANGED
|
@@ -146,7 +146,7 @@ import {
|
|
|
146
146
|
trimWords,
|
|
147
147
|
} from "./terminal-layout.mjs";
|
|
148
148
|
import { completedFlush, splitLiveStream } from "./completed-flush.mjs";
|
|
149
|
-
import { isScaffoldStep, isGroupableStep,
|
|
149
|
+
import { isScaffoldStep, isGroupableStep, stepGroupRows, stepRowSpans, relativizePaths } from "./step-group.mjs";
|
|
150
150
|
import { clearLogsNoticeText } from "./clear-logs.mjs";
|
|
151
151
|
import { commandAllowedIn, commandAllowProject, commandAllowSource, commandForget, commandProjectAllowed, sourcedFileOf, PROJECT_CHOICE } from "./command-allow.mjs";
|
|
152
152
|
import { allowIn, allowedIn, bridgeCommand, browserReport, bridgeStatus, extensionDir, findDevInstalls, helpInstall, installExtensionFiles, installSteps, localLeftovers, openExtensionsPage, removeLocalFiles, STORE_URL, stopBridge } from "./browser-command.mjs";
|
|
@@ -159,8 +159,9 @@ import { readHooks } from "./hooks-config.mjs";
|
|
|
159
159
|
import { readSkillSource, sourceLabel, SKILL_SOURCE_KEY } from "./skill-source.mjs";
|
|
160
160
|
import { codingBannerLabel, isOllamaCloudUrl, SECRET_KEY_HINT } from "./coding-key-prompt.mjs";
|
|
161
161
|
import { questionEchoText, thoughtPrintSeq, wrapDiffText } from "./terminal-layout.mjs";
|
|
162
|
+
import { focusReport, createMouseParking } from "./terminal-layout.mjs"; // GH #558
|
|
162
163
|
import { createTurnQueue, droppedNote } from "./turn-queue.mjs"; // GH #429: questions typed during a turn wait here
|
|
163
|
-
import { sendNote, takeUnread, sweepOldNotes, parseUserNote, questionWithNotes, USERNOTE_PREFIX } from "./turn-notes.mjs"; // GH #506: …or go to the running turn
|
|
164
|
+
import { sendNote, sendNow, createSendNowChord, waitingLabel, takeUnread, sweepOldNotes, parseUserNote, parseSay, questionWithNotes, USERNOTE_PREFIX, SAY_PREFIX } from "./turn-notes.mjs"; // GH #506: …or go to the running turn
|
|
164
165
|
import { globalPrefixOf } from "./install-path.mjs";
|
|
165
166
|
import { indentBlock, commandBlockRows, wrapIndented } from "./terminal-layout.mjs"; // every line of an Allow-prompt detail indented (#189); wrapped + collapsible command (#204)
|
|
166
167
|
import { firstGuOnPath, pathGuMismatch, guOnPathIsCurrent, updateAttemptRecord, repeatUpdateNotice } from "./update-verify.mjs";
|
|
@@ -173,6 +174,9 @@ import {
|
|
|
173
174
|
parseModelFallback,
|
|
174
175
|
} from "./model-fallback.mjs";
|
|
175
176
|
import { codingChoiceTags, coderDisplayName, coderWhere, whereOfActiveCoder } from "./coding-choice-tags.mjs";
|
|
177
|
+
import { LSP_OFFER_MS, OFFER_CHOICES, allLanguages, applyOfferAnswer, canInstall, lspById, lspHostPath, lspStatePath, offerRows, readLspState, resolveServer, writeLspState } from "./lsp-registry.mjs";
|
|
178
|
+
import { AUTOCOMPACT_ASK_MS, applyChoice, autocompactPath, commandChoices, describeAutocompact, parseAutocompactArg, readAutocompact, startupChoices, startupText, writeAutocompact } from "./autocompact.mjs";
|
|
179
|
+
import { ghostText, shouldSuggest, suggestNext, suggestionsOnFromFile, suggestionsToggle } from "./next-suggestion.mjs";
|
|
176
180
|
import { TITLE_POP, TITLE_PUSH, idleTitle, needsSummary, summariseForTitle, titleModel, titleSeq, trimTitle } from "./terminal-title.mjs";
|
|
177
181
|
import { IMAGE_NEEDS_CLAUDE, coderTakesImagesFor, loadCloudImageCoders, saveCloudImageCoders, clipboardImageToFile, fitImageNotice, imageMarkersForDisplay, createImageStore, imagePasteKey, imagePathFromPaste, isClaudeCoderUrl, isImagePasteKey, storeImageFile } from "./image-paste.mjs";
|
|
178
182
|
import {
|
|
@@ -602,8 +606,7 @@ const PICK_MANY_HINT = "↑/↓ · space toggles · ctrl+a all · Enter saves ·
|
|
|
602
606
|
// grows past it). A server saved with more before the rule keeps them: see extraModelRoom.
|
|
603
607
|
const MAX_ALT_CODERS = 2;
|
|
604
608
|
const BULLET = "●"; // a neutral completed action (informational step)
|
|
605
|
-
const
|
|
606
|
-
const CROSS = "✗"; // a step that FAILED
|
|
609
|
+
const CROSS = "✗"; // a step that FAILED (one that is not a command's — those join the group, GH #530)
|
|
607
610
|
const brightText = (s) => s; // default terminal colour (un-dimmed) — the "pops" text weight
|
|
608
611
|
// The "spotlight the answer" hierarchy: successes and neutral steps RECEDE (dim), a FAILURE
|
|
609
612
|
// POPS (red ✗ + full-bright text) — the one thing the user must not miss while everything
|
|
@@ -612,9 +615,11 @@ const brightText = (s) => s; // default terminal colour (un-dimmed) — the "pop
|
|
|
612
615
|
// forward reference here is a startup crash, not a lint warning.
|
|
613
616
|
const BULLET_STYLE = {
|
|
614
617
|
fail: { mark: CROSS, markColor: red, textColor: brightText },
|
|
615
|
-
//
|
|
616
|
-
|
|
617
|
-
|
|
618
|
+
// GH #530: commands (finished, failed, or a look-up that found nothing) and searches go into the
|
|
619
|
+
// counted group with NO mark — the ✓ in front of every one was noise. These two are what an
|
|
620
|
+
// ungroupable one falls back to: no mark (the slot stays a space so the text does not move).
|
|
621
|
+
soft: { mark: " ", markColor: dim, textColor: dim },
|
|
622
|
+
ok: { mark: " ", markColor: dim, textColor: dim },
|
|
618
623
|
// #383 (GitHub #173): a "●" row that stands alone is the agent saying something — a warning, a
|
|
619
624
|
// wait for approval — so its text is white. Look-ups and finished commands are activity and go
|
|
620
625
|
// into the dim counted group instead (step-group.mjs); they never reach this style.
|
|
@@ -734,6 +739,20 @@ if (REPL_LOG) {
|
|
|
734
739
|
console.log(dim(" --log: detailed logging is on for this run (~/.gonext/worker.log); back to minimal when gu closes."));
|
|
735
740
|
}
|
|
736
741
|
|
|
742
|
+
// WHAT THE INSTALL DID, FIRST (GH #557 follow-up): npm hides postinstall output, so gu says what
|
|
743
|
+
// it changed for the user (PATH, PowerShell's `gu` alias) before anything else it prints or asks.
|
|
744
|
+
// On this computer's first start it also checks those itself — npm can skip install scripts.
|
|
745
|
+
// Done, then said; never a reason not to start.
|
|
746
|
+
if (process.stdout.isTTY) {
|
|
747
|
+
try {
|
|
748
|
+
const { startupSetupReport } = await import("./setup-fixes.mjs");
|
|
749
|
+
const text = await startupSetupReport({ here: DIR, color: true });
|
|
750
|
+
if (text) console.log("\n" + text.replace(/^/gm, " ") + "\n");
|
|
751
|
+
} catch {
|
|
752
|
+
/* never blocks gu */
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
737
756
|
// THE AGENT'S PYTHON PACKAGES COME FIRST (GH #308), before the first-run setup and the terminal below create their readline and
|
|
738
757
|
// raw keyboard — and before stdout is hooked for the pinned input bar (whose state does not exist yet here): the install ran from inside the live terminal and froze it on a new Windows 11 machine.
|
|
739
758
|
{
|
|
@@ -1070,6 +1089,9 @@ const COMMANDS = [
|
|
|
1070
1089
|
// has already confused the person who built both. The descriptions carry the distinction.
|
|
1071
1090
|
{ name: "/model", desc: "switch the CODING model (the one that writes code) for this session" },
|
|
1072
1091
|
{ name: "/quick-models", desc: "pick up to 2 coding models to flip between with ← / → at the prompt" },
|
|
1092
|
+
{ name: "/lsp", desc: "language servers: the agent sees compile/type errors after each edit — status, on/off, restart" },
|
|
1093
|
+
{ name: "/autocompact", desc: "when older steps are compacted: near 400k tokens (default), another size, or near the model's limit" },
|
|
1094
|
+
{ name: "/suggestions", desc: "turn the suggested next message (Tab takes it) on or off" },
|
|
1073
1095
|
// /provider IS NOT LISTED HERE ANY MORE — see HIDDEN_COMMANDS. It was promoted to a top-level
|
|
1074
1096
|
// command when editing a provider was genuinely unreachable, and by the very next change
|
|
1075
1097
|
// /model carried "add or change a provider — Claude API, OpenAI, Kimi…" as a row in EVERY branch of
|
|
@@ -1274,7 +1296,8 @@ function pastQuestion(text) {
|
|
|
1274
1296
|
function waitingNoteRows() {
|
|
1275
1297
|
if (!following) return [];
|
|
1276
1298
|
const width = Math.max(20, process.stdout.columns || 80);
|
|
1277
|
-
const
|
|
1299
|
+
const notes = waitingNotes.filter((n) => !n.shown);
|
|
1300
|
+
const texts = [...notes.map((n) => n.text), ...turnQueue.list()];
|
|
1278
1301
|
const rows = [];
|
|
1279
1302
|
for (const t of texts) {
|
|
1280
1303
|
const lines = pastQuestion(t).replace(/\n+$/, "").split("\n").map((l) => stripAnsiEscapes(l));
|
|
@@ -1282,7 +1305,10 @@ function waitingNoteRows() {
|
|
|
1282
1305
|
if (lines.length > 3) rows.push(dim(`${GUTTER}… ${lines.length - 3} more line(s)`));
|
|
1283
1306
|
}
|
|
1284
1307
|
if (!rows.length) return [];
|
|
1285
|
-
|
|
1308
|
+
// GH #560: say what happens to it, as Claude Code does ("⎿ Queued · ctrl+x ctrl+s to send now").
|
|
1309
|
+
const label = waitingLabel({ notes: waitingNotes.length, queued: turnQueue.size, sending: sendNowPending });
|
|
1310
|
+
const body = rows.length > 6 ? [...rows.slice(0, 5), dim(`${GUTTER}… ${rows.length - 5} more line(s) waiting`)] : rows;
|
|
1311
|
+
return ["", ...body, ...(label ? [dim(clipVisible(`${GUTTER}${label}`, width - 1))] : [])];
|
|
1286
1312
|
}
|
|
1287
1313
|
function flushPendingEcho() {
|
|
1288
1314
|
if (pendingEcho === null) return;
|
|
@@ -1368,6 +1394,13 @@ const CLICK_TO_POSITION_ENABLED = true;
|
|
|
1368
1394
|
// readline's own reader).
|
|
1369
1395
|
const PASTE_MODE_ON = "\x1b[?2004h"; // ask the terminal to bracket pastes
|
|
1370
1396
|
const PASTE_MODE_OFF = "\x1b[?2004l";
|
|
1397
|
+
// Focus reporting (GH #558): the terminal sends ESC[I / ESC[O as the window gains and loses
|
|
1398
|
+
// focus, and gu lets go of the mouse while it is away — see createMouseParking.
|
|
1399
|
+
const FOCUS_MODE_ON = "\x1b[?1004h";
|
|
1400
|
+
const FOCUS_MODE_OFF = "\x1b[?1004l";
|
|
1401
|
+
// Assigned next to the mouse modes it switches (further down); `let` so input that arrives
|
|
1402
|
+
// before then finds null instead of a TDZ error.
|
|
1403
|
+
let mouseParking = null;
|
|
1371
1404
|
// The paste is BUFFERED here rather than passed through: readline never sees a single byte of
|
|
1372
1405
|
// it, so its newlines cannot submit the turn, and at paste-end we decide what to show — a
|
|
1373
1406
|
// short paste goes in literally, a long one becomes "[Pasted text #N +M lines]" with the real
|
|
@@ -1397,6 +1430,17 @@ function mouseFlush() {
|
|
|
1397
1430
|
_mouseTimer = null;
|
|
1398
1431
|
mouseReplay(mouseReader.flush());
|
|
1399
1432
|
}
|
|
1433
|
+
/**
|
|
1434
|
+
* GH #558: the window gained or lost focus → let go of / take back the mouse; true = it was a
|
|
1435
|
+
* focus report, swallow it. Anything else that reaches _ttyWrite is someone at the window.
|
|
1436
|
+
*/
|
|
1437
|
+
function onFocusOrActivity(key) {
|
|
1438
|
+
const focus = focusReport(key);
|
|
1439
|
+
if (focus === "out") mouseParking?.focusOut();
|
|
1440
|
+
else if (focus === "in") mouseParking?.focusIn();
|
|
1441
|
+
else mouseParking?.activity();
|
|
1442
|
+
return focus !== null;
|
|
1443
|
+
}
|
|
1400
1444
|
const _origTtyWrite = rl._ttyWrite.bind(rl);
|
|
1401
1445
|
rl._ttyWrite = (str, key) => {
|
|
1402
1446
|
// A LIST PICKER OWNS EVERY KEY WHILE IT IS UP, and this has to happen HERE rather than in the
|
|
@@ -1413,7 +1457,9 @@ rl._ttyWrite = (str, key) => {
|
|
|
1413
1457
|
// is up there is no line to edit, so anything readline does to `rl.line` — kill-to-end,
|
|
1414
1458
|
// word-delete, history — is invisible work on a buffer the user cannot see, which then
|
|
1415
1459
|
// surfaces the moment the picker closes.
|
|
1460
|
+
if (onFocusOrActivity(key)) return; // GH #558: focus in/out is not a key, whoever owns them
|
|
1416
1461
|
if (listPickerActive) return;
|
|
1462
|
+
if (nextHint && nextHintKey(str, key)) return; // GH #536: Tab takes the suggestion
|
|
1417
1463
|
if (key?.name === "paste-start") {
|
|
1418
1464
|
pasteBuffer = "";
|
|
1419
1465
|
return; // swallow the marker
|
|
@@ -1488,6 +1534,8 @@ rl._ttyWrite = (str, key) => {
|
|
|
1488
1534
|
}
|
|
1489
1535
|
if (verdict.action === "consume") {
|
|
1490
1536
|
mouseClearTimer();
|
|
1537
|
+
if (verdict.focus === "out") mouseParking?.focusOut(); // the ESC-timed-out shape (GH #558)
|
|
1538
|
+
else if (verdict.focus === "in") mouseParking?.focusIn();
|
|
1491
1539
|
if (verdict.report) applyMouseReport(verdict.report); // null: focus in/out, a win32 record
|
|
1492
1540
|
return;
|
|
1493
1541
|
}
|
|
@@ -1837,9 +1885,9 @@ function applyClick({ row, col }) {
|
|
|
1837
1885
|
rl._refreshLine();
|
|
1838
1886
|
}
|
|
1839
1887
|
if (IS_TTY) {
|
|
1840
|
-
ui(PASTE_MODE_ON);
|
|
1841
|
-
// Never leave the terminal in bracketed-paste mode — the user's shell would inherit it.
|
|
1842
|
-
process.on("exit", () => _stdoutWrite(PASTE_MODE_OFF));
|
|
1888
|
+
ui(PASTE_MODE_ON + FOCUS_MODE_ON);
|
|
1889
|
+
// Never leave the terminal in bracketed-paste or focus mode — the user's shell would inherit it.
|
|
1890
|
+
process.on("exit", () => _stdoutWrite(PASTE_MODE_OFF + FOCUS_MODE_OFF));
|
|
1843
1891
|
}
|
|
1844
1892
|
|
|
1845
1893
|
// THE TAB SAYS WHAT IS BEING WORKED ON (task #357) — see terminal-title.mjs. Until the first
|
|
@@ -1858,6 +1906,231 @@ if (TITLE_ON) {
|
|
|
1858
1906
|
process.on("exit", () => _stdoutWrite(titleSeq("") + TITLE_POP));
|
|
1859
1907
|
}
|
|
1860
1908
|
|
|
1909
|
+
// ---------- language servers (GH #539/#540) --------------------------------------------------
|
|
1910
|
+
// The choices live in ~/.gonext/lsp-state.json (the offer and /lsp write it); the worker's host
|
|
1911
|
+
// (lsp-host.mjs) reads it, runs the servers, and says what is running on /status.
|
|
1912
|
+
const loadLspState = () => {
|
|
1913
|
+
try {
|
|
1914
|
+
return readLspState(readFileSync(lspStatePath(homedir()), "utf8"));
|
|
1915
|
+
} catch {
|
|
1916
|
+
return readLspState("");
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
function saveLspState(state) {
|
|
1920
|
+
try {
|
|
1921
|
+
mkdirSync(dirname(lspStatePath(homedir())), { recursive: true });
|
|
1922
|
+
writeFileSync(lspStatePath(homedir()), writeLspState(state));
|
|
1923
|
+
} catch (e) {
|
|
1924
|
+
console.log(GUTTER + yellow(`could not save the language-server choice (${e?.message || e})`));
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
/** Ask the worker's host something (GET /status, POST /stop). null when no worker is running it. */
|
|
1929
|
+
async function lspHostCall(path, body = null) {
|
|
1930
|
+
try {
|
|
1931
|
+
const { url, token } = JSON.parse(readFileSync(lspHostPath(homedir()), "utf8"));
|
|
1932
|
+
const res = await fetch(url + path, {
|
|
1933
|
+
method: body ? "POST" : "GET",
|
|
1934
|
+
headers: { "X-Gu-Lsp-Token": token, "Content-Type": "application/json" },
|
|
1935
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
1936
|
+
signal: AbortSignal.timeout(3000),
|
|
1937
|
+
});
|
|
1938
|
+
return res.ok ? await res.json() : null;
|
|
1939
|
+
} catch {
|
|
1940
|
+
return null;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
/** One line per language: the choice, whether its server is here, and what is running. */
|
|
1945
|
+
function lspStatusLine(row) {
|
|
1946
|
+
const choice = { on: "on", off: "off", never: "off (never offered)" }[row.choice] ?? "not set — offered on the first edit";
|
|
1947
|
+
const where = row.installing ? "installing…" : row.installError ? `install failed: ${row.installError}` : row.found ? `${row.server} found` : row.canInstall ? `${row.server} not installed (gu can install it)` : `${row.server} not found${row.hint ? ` — ${row.hint}` : ""}`;
|
|
1948
|
+
const running = (row.running?.length ? ` · running in ${row.running.length} project${row.running.length > 1 ? "s" : ""}` : "") +
|
|
1949
|
+
// A heavy server (Java, Kotlin) can take minutes to read a project the first time (GH #543).
|
|
1950
|
+
(row.starting?.length ? ` · starting in ${row.starting.length} project${row.starting.length > 1 ? "s" : ""} (a first start can take minutes)` : "");
|
|
1951
|
+
return `${row.name}: ${choice} · ${where}${running}`;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
/** /lsp — what each language server is doing, and turn one on or off. */
|
|
1955
|
+
async function lspCommand(arg) {
|
|
1956
|
+
const [verb = "", which = ""] = String(arg ?? "").trim().toLowerCase().split(/\s+/);
|
|
1957
|
+
const ws = resolve(process.cwd());
|
|
1958
|
+
const langs = allLanguages({ home: homedir(), workspace: ws });
|
|
1959
|
+
const live = (await lspHostCall(`/status?workspace=${encodeURIComponent(ws)}`))?.languages;
|
|
1960
|
+
const st = loadLspState();
|
|
1961
|
+
const rows = live ?? langs.map((l) => ({
|
|
1962
|
+
id: l.id, name: l.name, server: l.server, choice: st.languages[l.id] ?? "", hint: l.hint ?? "",
|
|
1963
|
+
found: Boolean(resolveServer(l, { home: homedir() })), canInstall: canInstall(l), running: [],
|
|
1964
|
+
}));
|
|
1965
|
+
const set = async (id, on) => {
|
|
1966
|
+
const lang = lspById(id, langs);
|
|
1967
|
+
if (!lang) {
|
|
1968
|
+
console.log(GUTTER + dim(`no language "${id}" — ${langs.map((l) => l.id).join(", ")}`) + "\n");
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
const next = loadLspState();
|
|
1972
|
+
next.languages[id] = on ? "on" : "off";
|
|
1973
|
+
saveLspState(next);
|
|
1974
|
+
if (!on) await lspHostCall("/stop", { lang: id });
|
|
1975
|
+
const row = rows.find((r) => r.id === id);
|
|
1976
|
+
console.log(GUTTER + accent(`✓ ${lang.name} code intelligence ${on ? "on" : "off"}`) +
|
|
1977
|
+
dim(on && row && !row.found && canInstall(lang) ? ` — gu installs ${lang.server} at the next ${lang.name} edit` : "") + "\n");
|
|
1978
|
+
};
|
|
1979
|
+
if (verb === "on" || verb === "off") return set(which, verb === "on");
|
|
1980
|
+
if (verb === "restart") {
|
|
1981
|
+
await lspHostCall("/stop", { lang: which });
|
|
1982
|
+
console.log(GUTTER + dim("stopped — each server starts again at the next edit of its language.") + "\n");
|
|
1983
|
+
return;
|
|
1984
|
+
}
|
|
1985
|
+
console.log(GUTTER + accent("Language servers") + dim(" — the agent sees compile/type errors right after each edit"));
|
|
1986
|
+
for (const r of rows) console.log(GUTTER + " " + dim(lspStatusLine(r)));
|
|
1987
|
+
if (!live) console.log(GUTTER + dim(" (the worker is not running one right now)"));
|
|
1988
|
+
const items = [...rows.map((r) => (r.choice === "on" ? `Turn off ${r.name}` : `Turn on ${r.name}`)), "Restart all servers"];
|
|
1989
|
+
const idx = await pickFromList(items, 0);
|
|
1990
|
+
if (idx < 0) return console.log(GUTTER + dim("(unchanged)") + "\n");
|
|
1991
|
+
if (idx === rows.length) {
|
|
1992
|
+
await lspHostCall("/stop", { lang: "" });
|
|
1993
|
+
return console.log(GUTTER + dim("stopped — each server starts again at the next edit of its language.") + "\n");
|
|
1994
|
+
}
|
|
1995
|
+
await set(rows[idx].id, rows[idx].choice !== "on");
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
// ---------- autocompact (GH #538) ------------------------------------------------------------
|
|
1999
|
+
// When the agent compacts a turn's older steps: asked once per computer (no answer = 400k, all
|
|
2000
|
+
// models), changed with /autocompact. The agent reads the same file. See autocompact.mjs.
|
|
2001
|
+
const AUTOCOMPACT_FILE = autocompactPath(homedir());
|
|
2002
|
+
const loadAutocompact = () => {
|
|
2003
|
+
try {
|
|
2004
|
+
return readAutocompact(readFileSync(AUTOCOMPACT_FILE, "utf8"));
|
|
2005
|
+
} catch {
|
|
2006
|
+
return readAutocompact("");
|
|
2007
|
+
}
|
|
2008
|
+
};
|
|
2009
|
+
function saveAutocompact(state) {
|
|
2010
|
+
mkdirSync(dirname(AUTOCOMPACT_FILE), { recursive: true });
|
|
2011
|
+
writeFileSync(AUTOCOMPACT_FILE, writeAutocompact(state));
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
/** The startup question — only when it has never been answered, and only on a terminal. */
|
|
2015
|
+
async function askAutocompactOnce() {
|
|
2016
|
+
if (!process.stdin.isTTY || loadAutocompact().answered) return;
|
|
2017
|
+
const model = activeCodingModelId();
|
|
2018
|
+
const { title, body } = startupText();
|
|
2019
|
+
console.log(GUTTER + accent(title) + dim(` (no answer in ${AUTOCOMPACT_ASK_MS / 1000}s = Apply, all models)`));
|
|
2020
|
+
console.log(wrapGutter(body, dim));
|
|
2021
|
+
const choices = startupChoices(model);
|
|
2022
|
+
const idx = await pickFromList(choices.map((c) => c.label), 0, { timeoutMs: AUTOCOMPACT_ASK_MS, timeoutIndex: 0 });
|
|
2023
|
+
// Esc (or anything that is not a row) is "not choosing" — and not choosing means the default.
|
|
2024
|
+
const pick = choices[idx] ?? choices[0];
|
|
2025
|
+
const state = applyChoice(loadAutocompact(), pick.apply, model);
|
|
2026
|
+
try {
|
|
2027
|
+
saveAutocompact(state);
|
|
2028
|
+
console.log(GUTTER + accent("✓ " + describeAutocompact(state, model)) + "\n");
|
|
2029
|
+
} catch (e) {
|
|
2030
|
+
console.log(GUTTER + yellow(`could not save the autocompact choice (${e?.message || e}) — gu will ask again next time.`) + "\n");
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
/** /autocompact [<tokens>|keep] — a picker without an argument, all models with one. */
|
|
2035
|
+
async function autocompactCommand(arg) {
|
|
2036
|
+
const model = activeCodingModelId();
|
|
2037
|
+
let state = loadAutocompact();
|
|
2038
|
+
if (String(arg ?? "").trim()) {
|
|
2039
|
+
const parsed = parseAutocompactArg(arg);
|
|
2040
|
+
if (!parsed) {
|
|
2041
|
+
console.log(GUTTER + dim("usage: /autocompact · /autocompact 400k · /autocompact keep") + "\n");
|
|
2042
|
+
return;
|
|
2043
|
+
}
|
|
2044
|
+
state = applyChoice(state, { scope: "all", cap: parsed.cap }, model);
|
|
2045
|
+
} else {
|
|
2046
|
+
console.log(GUTTER + dim(describeAutocompact(state, model)));
|
|
2047
|
+
const { rows, current } = commandChoices(state, model);
|
|
2048
|
+
const idx = await pickFromList(rows.map((r) => r.label), current);
|
|
2049
|
+
if (idx < 0 || !rows[idx]) {
|
|
2050
|
+
console.log(GUTTER + dim("(unchanged)") + "\n");
|
|
2051
|
+
return;
|
|
2052
|
+
}
|
|
2053
|
+
state = applyChoice(state, rows[idx].apply, model);
|
|
2054
|
+
}
|
|
2055
|
+
try {
|
|
2056
|
+
saveAutocompact(state);
|
|
2057
|
+
console.log(GUTTER + accent("✓ " + describeAutocompact(state, model)) + dim(" · from the next turn") + "\n");
|
|
2058
|
+
} catch (e) {
|
|
2059
|
+
console.log(GUTTER + yellow(`could not save it (${e?.message || e})`) + "\n");
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
// ---------- the next message, suggested (GH #536) -------------------------------------------
|
|
2064
|
+
// After SOME turns the empty input shows a dim suggestion; Tab puts it in the input. See
|
|
2065
|
+
// next-suggestion.mjs for when (two gates: cheap rules, then the coder answering NONE or a reply).
|
|
2066
|
+
const SUGGESTIONS_FILE = join(homedir(), ".gonext", "prompt-suggestions");
|
|
2067
|
+
let suggestionsOn = (() => {
|
|
2068
|
+
try {
|
|
2069
|
+
return suggestionsOnFromFile(readFileSync(SUGGESTIONS_FILE, "utf8"));
|
|
2070
|
+
} catch {
|
|
2071
|
+
return true; // never set: on
|
|
2072
|
+
}
|
|
2073
|
+
})();
|
|
2074
|
+
let nextHint = ""; // the suggestion on screen now, "" when none
|
|
2075
|
+
let _nextHintSeq = 0; // bumped by anything that makes a pending suggestion stale
|
|
2076
|
+
|
|
2077
|
+
/** Take the suggestion away (typing, Esc, a new question, a later turn). */
|
|
2078
|
+
function clearNextHint() {
|
|
2079
|
+
_nextHintSeq++;
|
|
2080
|
+
if (!nextHint) return;
|
|
2081
|
+
nextHint = "";
|
|
2082
|
+
paintBar();
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
/**
|
|
2086
|
+
* A key while a suggestion is shown (called from _ttyWrite). Tab TAKES it into the input — not
|
|
2087
|
+
* sent, to edit or Enter — and the key is used up (→ true). Anything else the user does with the
|
|
2088
|
+
* keyboard (typing, Esc, arrows, Enter, a paste) puts it away and goes on as usual; Shift+Tab
|
|
2089
|
+
* (the edit mode) leaves it.
|
|
2090
|
+
*/
|
|
2091
|
+
function nextHintKey(str, key) {
|
|
2092
|
+
if (key?.name === "tab" && !key.shift && !key.ctrl && !key.meta && promptIdleForHint()) {
|
|
2093
|
+
const take = nextHint;
|
|
2094
|
+
clearNextHint();
|
|
2095
|
+
rl.line = take;
|
|
2096
|
+
rl.cursor = take.length;
|
|
2097
|
+
rl._refreshLine();
|
|
2098
|
+
paintBar();
|
|
2099
|
+
return true;
|
|
2100
|
+
}
|
|
2101
|
+
const typing = (key?.name && key.name !== "tab") || (typeof str === "string" && str.length > 0 && !str.startsWith("\x1b"));
|
|
2102
|
+
if (typing) clearNextHint();
|
|
2103
|
+
return false;
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
/** Is the prompt idle and empty — the only state a suggestion may be drawn into? */
|
|
2107
|
+
const promptIdleForHint = () =>
|
|
2108
|
+
barPinned() && footerActive && inputVisible && !following && rl.line === "" && !askWaiting && !secretInput
|
|
2109
|
+
&& !inlinePrompt && !slashOverlayActive && !listPickerActive && !approvalActive && !zonePanel;
|
|
2110
|
+
|
|
2111
|
+
/**
|
|
2112
|
+
* After a completed turn: ask the coder it ran on for the obvious next message, in the background.
|
|
2113
|
+
* Fire-and-forget like the title: never delays anything, never prints, and a reply that arrives
|
|
2114
|
+
* after the user started typing (or asked something else) is thrown away.
|
|
2115
|
+
*/
|
|
2116
|
+
function offerNextHint(question, answer) {
|
|
2117
|
+
clearNextHint();
|
|
2118
|
+
if (!shouldSuggest({ question, answer, enabled: suggestionsOn })) return;
|
|
2119
|
+
const mine = _nextHintSeq;
|
|
2120
|
+
void (async () => {
|
|
2121
|
+
const settings = await fetchWorkerSettings();
|
|
2122
|
+
if (!settings || mine !== _nextHintSeq) return;
|
|
2123
|
+
const target = titleModel(settings, { url: activeCodingUrl(), model: activeCodingModelId() });
|
|
2124
|
+
if (!target) return;
|
|
2125
|
+
const key = target.backendId ? await fetchKeyForBackend(target.backendId) : null;
|
|
2126
|
+
if (mine !== _nextHintSeq) return;
|
|
2127
|
+
const hint = await suggestNext({ question, answer }, { fetchImpl: doctorFetch, target, apiKey: key?.apiKey ?? "" });
|
|
2128
|
+
if (!hint || mine !== _nextHintSeq || !promptIdleForHint()) return;
|
|
2129
|
+
nextHint = hint;
|
|
2130
|
+
paintBar();
|
|
2131
|
+
})().catch(() => {});
|
|
2132
|
+
}
|
|
2133
|
+
|
|
1861
2134
|
/**
|
|
1862
2135
|
* A new question: the trimmed text now, and — only when it had to be cut — the agent model's
|
|
1863
2136
|
* few-word summary whenever it arrives. Fire-and-forget by design: it never delays the turn,
|
|
@@ -2264,7 +2537,8 @@ rl.on("line", (l) => {
|
|
|
2264
2537
|
if (queued && currentJobId && !cancelRequested && sendNote(currentJobId, queued)) {
|
|
2265
2538
|
waitingNotes.push({ text: queued, shown: !barPinned() });
|
|
2266
2539
|
if (barPinned()) paintBar();
|
|
2267
|
-
|
|
2540
|
+
// GH #566: unpinned, the message goes straight into the history — and its hint with it, or there was none at all.
|
|
2541
|
+
else process.stdout.write("\n" + pastQuestion(queued) + dim(`${GUTTER}${waitingLabel({ notes: 1 })}`) + "\n");
|
|
2268
2542
|
return;
|
|
2269
2543
|
}
|
|
2270
2544
|
if (queued) {
|
|
@@ -3386,6 +3660,8 @@ function frozenZone() {
|
|
|
3386
3660
|
// clipboard.
|
|
3387
3661
|
selection: secretInput ? null : inputSelection,
|
|
3388
3662
|
highlight: highlightRow,
|
|
3663
|
+
// GH #536: the suggested next message, while the prompt is idle and empty.
|
|
3664
|
+
ghost: nextHint && promptIdleForHint() ? dim(ghostText(nextHint)) : "",
|
|
3389
3665
|
});
|
|
3390
3666
|
const footer = footerBuilt();
|
|
3391
3667
|
const rows = status.concat(notice ? [notice.row] : [], zone.rows, askHintRows(width), footer.rows);
|
|
@@ -3967,6 +4243,23 @@ const hoverCtl = createHoverController({
|
|
|
3967
4243
|
* lines 2×", one row until it is clicked open. They differ only in how their rows are made, so
|
|
3968
4244
|
* that is the one place they are told apart.
|
|
3969
4245
|
*/
|
|
4246
|
+
/**
|
|
4247
|
+
* One row of a step group, painted (GH #530): dim, or bright while hovered; the command count bold
|
|
4248
|
+
* and "1 failed" red — the only part of the row that asks to be read. Hovered, the row is one
|
|
4249
|
+
* bright run (the cue it opens): neighbouring spans of one colour are painted together.
|
|
4250
|
+
*/
|
|
4251
|
+
const paintStepRow = (text, hovered) => {
|
|
4252
|
+
const plain = (s) => (hovered ? hoverThought(s) : dim(s));
|
|
4253
|
+
const spanPaint = { count: hovered ? plain : bold, failed: red };
|
|
4254
|
+
const runs = [];
|
|
4255
|
+
for (const sp of stepRowSpans(text)) {
|
|
4256
|
+
const fn = spanPaint[sp.style] ?? plain;
|
|
4257
|
+
if (runs.length && runs[runs.length - 1].fn === fn) runs[runs.length - 1].text += sp.text;
|
|
4258
|
+
else runs.push({ fn, text: sp.text });
|
|
4259
|
+
}
|
|
4260
|
+
return runs.map((x) => x.fn(x.text)).join("");
|
|
4261
|
+
};
|
|
4262
|
+
|
|
3970
4263
|
const paintThoughtRows = (block, hovered, collapsed = block.collapsed) => {
|
|
3971
4264
|
if (block.kind === "command") {
|
|
3972
4265
|
// #204: the Allow prompt's command — wrapped under its own indent, long ones collapsed.
|
|
@@ -3974,12 +4267,8 @@ const paintThoughtRows = (block, hovered, collapsed = block.collapsed) => {
|
|
|
3974
4267
|
return commandBlockRows(block.text, { width: commandWidth(), indent: GUTTER, collapsed, maxRows: COMMAND_COLLAPSED_ROWS }).map(paint);
|
|
3975
4268
|
}
|
|
3976
4269
|
if (block.kind === "steps") {
|
|
3977
|
-
// Activity (look-ups,
|
|
3978
|
-
|
|
3979
|
-
const ok = stepGroupMark(block.items) === "ok";
|
|
3980
|
-
return stepGroupRows(block.items, { width: thoughtWidth(), collapsed }).map(
|
|
3981
|
-
(r) => (r.head ? markLine(ok ? accent(CHECK) : dim(BULLET)) : GUTTER) + paint(r.text)
|
|
3982
|
-
);
|
|
4270
|
+
// Activity (look-ups, commands): dim, bright while hovered, NO mark (GH #530).
|
|
4271
|
+
return stepGroupRows(block.items, { width: thoughtWidth(), collapsed }).map((r) => GUTTER + paintStepRow(r.text, hovered));
|
|
3983
4272
|
}
|
|
3984
4273
|
// THE AGENT'S OWN WORDS ARE WHITE (#383, GitHub #173) — what it found, what it will do next.
|
|
3985
4274
|
// They were grey scaffolding (#148), as dim as the commands, and the user missed them; now
|
|
@@ -4836,6 +5125,7 @@ if (process.stdin.isTTY) {
|
|
|
4836
5125
|
// for the whole paste window; `pasteBuffer` is opened on the paste-start event, which is
|
|
4837
5126
|
// fully dispatched before the first payload key arrives.
|
|
4838
5127
|
if (pasteBuffer !== null) return;
|
|
5128
|
+
if (focusReport(key)) return; // switching windows is not typing (GH #558)
|
|
4839
5129
|
// The wheel is not the keyboard (see trackMouseKey): scrolling must not count as typing,
|
|
4840
5130
|
// or it undoes itself.
|
|
4841
5131
|
if (trackMouseKey(_ch, key)) return;
|
|
@@ -4858,6 +5148,7 @@ if (process.stdin.isTTY) {
|
|
|
4858
5148
|
// re-rendered the slash overlay (the line still starts with "/" from before the paste) and
|
|
4859
5149
|
// re-walked the paste store. Same for a mouse report's characters, which are not keys.
|
|
4860
5150
|
if (pasteBuffer !== null) return;
|
|
5151
|
+
if (focusReport(key)) return; // GH #558
|
|
4861
5152
|
if (inMouseKeyWindow()) {
|
|
4862
5153
|
turnTyping.reset(); // a held "[" was the start of that report (GH #382)
|
|
4863
5154
|
return;
|
|
@@ -4906,6 +5197,21 @@ if (process.stdin.isTTY) {
|
|
|
4906
5197
|
// so the switch did nothing while the agent was thinking — which is exactly when a user
|
|
4907
5198
|
// watching it reach for commands wants to change it.
|
|
4908
5199
|
if (key && key.name === "tab" && key.shift) switchEditMode();
|
|
5200
|
+
// GH #560: Ctrl+X Ctrl+S — what was typed for the running turn is read NOW (see turn-notes.mjs).
|
|
5201
|
+
if (sendNowChord.feed(key)) {
|
|
5202
|
+
if (waitingNotes.length && currentJobId && !cancelRequested && sendNow(currentJobId)) {
|
|
5203
|
+
sendNowPending = true;
|
|
5204
|
+
}
|
|
5205
|
+
rl.line = typedDuringTurn ? turnDraft : "";
|
|
5206
|
+
rl.cursor = rl.line.length;
|
|
5207
|
+
if (barPinned()) paintBar();
|
|
5208
|
+
return;
|
|
5209
|
+
}
|
|
5210
|
+
if (sendNowChord.armed) {
|
|
5211
|
+
rl.line = typedDuringTurn ? turnDraft : "";
|
|
5212
|
+
rl.cursor = rl.line.length;
|
|
5213
|
+
return;
|
|
5214
|
+
}
|
|
4909
5215
|
// A printable key (or Enter after one) means the user is typing a question that will not
|
|
4910
5216
|
// be sent — say so in the input row now, not after they have typed the whole thing (#258).
|
|
4911
5217
|
// Not every printable key is typing: a mouse report or cursor reply whose ESC came alone
|
|
@@ -5042,7 +5348,7 @@ const MOUSE_OFF = "\x1b[?1003l\x1b[?1002l\x1b[?1000l\x1b[?1006l";
|
|
|
5042
5348
|
let _mouseEnabled = false;
|
|
5043
5349
|
const enableMouse = () => {
|
|
5044
5350
|
if (!hoverMouse || _mouseEnabled || !process.stdin.isTTY) return;
|
|
5045
|
-
ui(MOUSE_ON);
|
|
5351
|
+
if (!mouseParking?.parked()) ui(MOUSE_ON); // away (GH #558): focus-in turns it on
|
|
5046
5352
|
_mouseEnabled = true;
|
|
5047
5353
|
};
|
|
5048
5354
|
const disableMouse = () => {
|
|
@@ -5051,7 +5357,7 @@ const disableMouse = () => {
|
|
|
5051
5357
|
_mouseEnabled = false;
|
|
5052
5358
|
// MOUSE_OFF clears ?1000/?1006 as well, which is OUR wheel + click capture (task #141) —
|
|
5053
5359
|
// put it straight back, or scrolling silently returns to the terminal after a /hover turn.
|
|
5054
|
-
if (_clickEnabled) ui(CLICK_ON);
|
|
5360
|
+
if (_clickEnabled && !mouseParking?.parked()) ui(CLICK_ON);
|
|
5055
5361
|
};
|
|
5056
5362
|
// ---------- click-to-position the caret at the PROMPT (task #137) ------------------------
|
|
5057
5363
|
// BUTTON-ONLY reporting (?1000h), NOT the any-motion ?1003h the hover feature uses: a click
|
|
@@ -5085,8 +5391,10 @@ const enableClickToPosition = () => {
|
|
|
5085
5391
|
if (_clickEnabled || !process.stdin.isTTY) return;
|
|
5086
5392
|
// Never fight the hover mode: ?1003h already reports clicks, so if it's on, leave it alone.
|
|
5087
5393
|
// Bracketed paste is enabled once at startup (see the _ttyWrite wrap), not here.
|
|
5088
|
-
if (CLICK_TO_POSITION_ENABLED && !_mouseEnabled) ui(CLICK_ON);
|
|
5394
|
+
if (CLICK_TO_POSITION_ENABLED && !_mouseEnabled && !mouseParking?.parked()) ui(CLICK_ON);
|
|
5089
5395
|
_clickEnabled = true;
|
|
5396
|
+
// A new prompt starts the idle clock over SSH (GH #558) without taking a let-go mouse back.
|
|
5397
|
+
mouseParking?.arm();
|
|
5090
5398
|
};
|
|
5091
5399
|
const disableClickToPosition = () => {
|
|
5092
5400
|
if (!_clickEnabled) return;
|
|
@@ -5098,6 +5406,21 @@ const disableClickToPosition = () => {
|
|
|
5098
5406
|
_clickEnabled = false;
|
|
5099
5407
|
};
|
|
5100
5408
|
|
|
5409
|
+
// GH #558: let go of the mouse while the window is away, so a gu that dies without exiting (an
|
|
5410
|
+
// SSH connection reset, kill -9) cannot leave the terminal reporting every move to the shell.
|
|
5411
|
+
// The idle release is for SSH only: a local gu that exits clears the modes itself.
|
|
5412
|
+
const MOUSE_IDLE_MS = 3 * 60 * 1000;
|
|
5413
|
+
mouseParking = createMouseParking({
|
|
5414
|
+
idleMs: process.env.SSH_CONNECTION || process.env.SSH_TTY ? MOUSE_IDLE_MS : 0,
|
|
5415
|
+
release: () => {
|
|
5416
|
+
if (_mouseEnabled || _clickEnabled) ui(MOUSE_OFF);
|
|
5417
|
+
},
|
|
5418
|
+
restore: () => {
|
|
5419
|
+
if (_mouseEnabled) ui(MOUSE_ON);
|
|
5420
|
+
else if (_clickEnabled && CLICK_TO_POSITION_ENABLED) ui(CLICK_ON);
|
|
5421
|
+
},
|
|
5422
|
+
});
|
|
5423
|
+
process.on("exit", () => mouseParking.stop());
|
|
5101
5424
|
// Safety net: never leave the user's terminal in mouse-reporting mode (would break their
|
|
5102
5425
|
// shell's selection) if we exit ungracefully.
|
|
5103
5426
|
process.on("exit", disableMouse);
|
|
@@ -6539,6 +6862,35 @@ async function chooseCodingModelFrom(ps, all, question, current, { back = false
|
|
|
6539
6862
|
* unlisted one may be exactly right.
|
|
6540
6863
|
*/
|
|
6541
6864
|
async function chooseFromModelList(all, question, current = 0, { back = false, notes = null } = {}) {
|
|
6865
|
+
// GH #570: a long "company/model" list (OpenRouter: 436 models) is picked in two steps — the company, then its
|
|
6866
|
+
// models — instead of one endless scroll. ← back from the models returns to the companies.
|
|
6867
|
+
const cs = await import("./coding-provider-setup.mjs");
|
|
6868
|
+
const groups = cs.modelGroups(all);
|
|
6869
|
+
if (groups) {
|
|
6870
|
+
const cur = typeof current === "string" ? current : all[Number(current) || 0] ?? "";
|
|
6871
|
+
let gAt = Math.max(0, groups.findIndex((g) => g.ids.includes(cur)));
|
|
6872
|
+
for (;;) {
|
|
6873
|
+
const gi = await pickFromList([...groups.map((g) => `${g.name}${dim(` (${g.ids.length})`)}`), "type a model name…"], gAt, {
|
|
6874
|
+
back,
|
|
6875
|
+
header: () => [dim(` ${question} — first the company (${PICK_HINT})`)],
|
|
6876
|
+
headerRows: 1,
|
|
6877
|
+
});
|
|
6878
|
+
if (gi === PICK_BACK) return BACK;
|
|
6879
|
+
if (gi < 0) return null;
|
|
6880
|
+
if (gi === groups.length) {
|
|
6881
|
+
const typed = (await ask(" model name: ")).trim();
|
|
6882
|
+
return typed || null;
|
|
6883
|
+
}
|
|
6884
|
+
gAt = gi;
|
|
6885
|
+
const ids = groups[gi].ids;
|
|
6886
|
+
const r = await chooseFromModelList(ids, question, Math.max(0, ids.indexOf(cur)), {
|
|
6887
|
+
back: true,
|
|
6888
|
+
notes: notes ? ids.map((id) => notes[all.indexOf(id)]) : null,
|
|
6889
|
+
});
|
|
6890
|
+
if (r === BACK) continue;
|
|
6891
|
+
return r;
|
|
6892
|
+
}
|
|
6893
|
+
}
|
|
6542
6894
|
// `notes` (GH #397): a dim note per row ("an audio/speech model"), as /agent-model's own list has.
|
|
6543
6895
|
const rows = [...all.map((m, i) => (notes?.[i] ? `${m}${dim(` · ${notes[i]}`)}` : m)), "type a model name…"];
|
|
6544
6896
|
const at = typeof current === "string" ? all.indexOf(current) : Number(current) || 0;
|
|
@@ -7837,6 +8189,7 @@ function withTerminalHandedOver(run, { keepScreen = false } = {}) {
|
|
|
7837
8189
|
disableMouse();
|
|
7838
8190
|
disableClickToPosition();
|
|
7839
8191
|
ui(PASTE_MODE_OFF);
|
|
8192
|
+
ui(FOCUS_MODE_OFF); // an editor or pager must not receive our focus reports
|
|
7840
8193
|
if (!keepScreen) unpinBar();
|
|
7841
8194
|
const wasRaw = Boolean(process.stdin.isRaw);
|
|
7842
8195
|
try {
|
|
@@ -7855,6 +8208,7 @@ function withTerminalHandedOver(run, { keepScreen = false } = {}) {
|
|
|
7855
8208
|
}
|
|
7856
8209
|
rl.resume();
|
|
7857
8210
|
ui(PASTE_MODE_ON);
|
|
8211
|
+
ui(FOCUS_MODE_ON);
|
|
7858
8212
|
if (hadHover) enableMouse();
|
|
7859
8213
|
if (hadClick) enableClickToPosition();
|
|
7860
8214
|
// The window may have been resized while the editor ran, and no resize event reached us.
|
|
@@ -8938,6 +9292,20 @@ async function loadPrices({ force = false } = {}) {
|
|
|
8938
9292
|
return priceRows;
|
|
8939
9293
|
}
|
|
8940
9294
|
|
|
9295
|
+
/** GH #570: OpenRouter's published prices, fetched once per session (public, no key); [] when unreachable. */
|
|
9296
|
+
let openRouterPriceRows = null;
|
|
9297
|
+
async function openRouterPrices() {
|
|
9298
|
+
if (openRouterPriceRows) return openRouterPriceRows;
|
|
9299
|
+
try {
|
|
9300
|
+
const mp = await import("./model-prices.mjs");
|
|
9301
|
+
const r = await fetch("https://openrouter.ai/api/v1/models", { signal: AbortSignal.timeout(8000) });
|
|
9302
|
+
openRouterPriceRows = r.ok ? mp.openRouterPriceRows(await r.json()) : [];
|
|
9303
|
+
} catch {
|
|
9304
|
+
openRouterPriceRows = [];
|
|
9305
|
+
}
|
|
9306
|
+
return openRouterPriceRows;
|
|
9307
|
+
}
|
|
9308
|
+
|
|
8941
9309
|
/** The coder model id in use — the folder's /model pick ("<kind>::<model>") or the account default. */
|
|
8942
9310
|
function activeCodingModelId() {
|
|
8943
9311
|
const m = String(sessionCodingModel || "");
|
|
@@ -8961,6 +9329,8 @@ async function noteTurnCost(inputTokens, breakdown, coder = null) {
|
|
|
8961
9329
|
price = fm.freeModelPriceRow(freeModel, url, model);
|
|
8962
9330
|
}
|
|
8963
9331
|
price ??= mp.findPrice(rows, url, model);
|
|
9332
|
+
// GH #570: OpenRouter models are not in the table; their price comes from OpenRouter's own public list.
|
|
9333
|
+
if (!price && mp.hostOf(url) === "openrouter.ai") price = mp.findPrice(await openRouterPrices(), url, model);
|
|
8964
9334
|
const cache = readTurnCache(breakdown) ?? { cached: 0, cacheReported: false, firstIn: 0 };
|
|
8965
9335
|
const c = mp.turnCost({ input: inputTokens, ...cache, price });
|
|
8966
9336
|
if (!c) {
|
|
@@ -9123,7 +9493,7 @@ async function runVoucherCommand(line = "/voucher") {
|
|
|
9123
9493
|
const state = await ct.readState(dir);
|
|
9124
9494
|
const { DEFAULT_API_BASE } = await import("./device-login.mjs");
|
|
9125
9495
|
const device = await ct.thisDevice({ instanceId: myInstanceId || "" }).catch(() => null);
|
|
9126
|
-
const
|
|
9496
|
+
const redeem = (ageConfirmed) => withPendingStatus("checking the voucher", () =>
|
|
9127
9497
|
ct.redeemVoucher({
|
|
9128
9498
|
mode: isClientExpert() ? "expert" : "client",
|
|
9129
9499
|
apiBase,
|
|
@@ -9131,8 +9501,28 @@ async function runVoucherCommand(line = "/voucher") {
|
|
|
9131
9501
|
token: state.token,
|
|
9132
9502
|
device,
|
|
9133
9503
|
code,
|
|
9504
|
+
ageConfirmed,
|
|
9134
9505
|
})
|
|
9135
9506
|
);
|
|
9507
|
+
let r = await redeem(false);
|
|
9508
|
+
// GH #567: a gu + Gemini code — the same 18+ question the web page asks, here; nothing is used on a no.
|
|
9509
|
+
if (!r.ok && r.why === "gemini-age") {
|
|
9510
|
+
const m = Number(r.months) || 1;
|
|
9511
|
+
console.log(GUTTER + `This code is ${accent("gu + Gemini")} — ${m} month${m === 1 ? "" : "s"} of Google's Gemini models in gu.`);
|
|
9512
|
+
const a = String((await askOr("", () => ask(`${GUTTER}Are you 18 or older? [y/N]: `))) ?? "").trim().toLowerCase();
|
|
9513
|
+
if (!/^y(es)?$/.test(a)) {
|
|
9514
|
+
console.log(GUTTER + dim("Not used — the code is still good.") + "\n");
|
|
9515
|
+
return;
|
|
9516
|
+
}
|
|
9517
|
+
r = await redeem(true);
|
|
9518
|
+
}
|
|
9519
|
+
if (r.ok && r.kind === "gemini") {
|
|
9520
|
+
console.log(GUTTER + accent(`✓ gu + Gemini: ${r.months} month${r.months === 1 ? "" : "s"}`) + (r.paidUntil ? dim(` (until ${ct.shortDate(r.paidUntil)})`) : "") + ".");
|
|
9521
|
+
await addGeminiWhenReady(r.token || state.token);
|
|
9522
|
+
console.log("");
|
|
9523
|
+
if (barPinned()) paintBar();
|
|
9524
|
+
return;
|
|
9525
|
+
}
|
|
9136
9526
|
if (!r.ok) {
|
|
9137
9527
|
console.log(GUTTER + yellow(r.error) + "\n");
|
|
9138
9528
|
return;
|
|
@@ -9161,6 +9551,34 @@ async function runVoucherCommand(line = "/voucher") {
|
|
|
9161
9551
|
if (barPinned()) paintBar();
|
|
9162
9552
|
}
|
|
9163
9553
|
|
|
9554
|
+
/**
|
|
9555
|
+
* GH #567: after a gu + Gemini code, Google sets up this holder's own project (about a minute). Ask for the preset
|
|
9556
|
+
* until it carries Gemini with its key, then apply it: the Gemini provider and its models go into /model by
|
|
9557
|
+
* themselves — nobody adds a provider by hand. After 90 s it stops waiting: every start of gu fetches the preset.
|
|
9558
|
+
*/
|
|
9559
|
+
const GEMINI_HOST_RE = /generativelanguage\.googleapis\.com/;
|
|
9560
|
+
async function addGeminiWhenReady(token) {
|
|
9561
|
+
const fm = await import("./free-model.mjs");
|
|
9562
|
+
const gemOf = (p) => fm.presetProviders(p).find((x) => GEMINI_HOST_RE.test(x.baseUrl) && x.apiKey);
|
|
9563
|
+
const ready = await withPendingStatus("Google is setting up your Gemini (about a minute)", async () => {
|
|
9564
|
+
for (const started = Date.now(); Date.now() - started < 90_000; await new Promise((res) => setTimeout(res, 8_000))) {
|
|
9565
|
+
const got = await fm.fetchPreset({ hostedBase: await freeModelHostedBase(), token }).catch(() => ({ ok: false }));
|
|
9566
|
+
if (got.ok && gemOf(got.preset)) return got.preset;
|
|
9567
|
+
}
|
|
9568
|
+
return null;
|
|
9569
|
+
});
|
|
9570
|
+
if (!ready) {
|
|
9571
|
+
console.log(GUTTER + dim("Gemini is still being set up — gu adds it to /model by itself at its next start."));
|
|
9572
|
+
return false;
|
|
9573
|
+
}
|
|
9574
|
+
// GH #569: applied as a fresh choice, like loading a preset by hand — the Gemini row, its key and its models are added
|
|
9575
|
+
// and its model is chosen (the service puts the code redeemed last first), whatever plan this computer is on.
|
|
9576
|
+
await setUpFreeModel({ token, announce: true });
|
|
9577
|
+
const ids = (gemOf(ready)?.models ?? []).map((m) => m.id);
|
|
9578
|
+
console.log(GUTTER + accent("✓ Gemini added to /model") + dim(ids.length ? ` — ${ids.join(", ")}` : ""));
|
|
9579
|
+
return true;
|
|
9580
|
+
}
|
|
9581
|
+
|
|
9164
9582
|
async function runPricesCommand(line = "/prices") {
|
|
9165
9583
|
const mp = await import("./model-prices.mjs");
|
|
9166
9584
|
console.log("");
|
|
@@ -11712,6 +12130,8 @@ let followingAttached = false;
|
|
|
11712
12130
|
let followAborted = false;
|
|
11713
12131
|
// GH #506/#514: what was typed during this turn — waiting for the agent, and what it has read.
|
|
11714
12132
|
let waitingNotes = []; // {text, shown} — shown: already in the history (unpinned)
|
|
12133
|
+
let sendNowPending = false; // GH #560: Ctrl+X Ctrl+S pressed; cleared when the agent reads the notes
|
|
12134
|
+
const sendNowChord = createSendNowChord();
|
|
11715
12135
|
let readNotes = []; // texts the agent read, kept with this turn's question
|
|
11716
12136
|
let currentJobId = null; // the running turn's jobId — so Ctrl+C can cancel it server-side
|
|
11717
12137
|
let cancelRequested = false; // a cancel POST has been sent for the current turn
|
|
@@ -11857,6 +12277,8 @@ const MCPTOOL_PREFIX = "__MCPTOOL__::";
|
|
|
11857
12277
|
// The agent's first use of the browser in a turn (#150): "<folder>\t<what it is about to do>".
|
|
11858
12278
|
// "Always" puts the folder on ~/.gonext/browser-allow.json, which the agent reads before asking.
|
|
11859
12279
|
const BROWSER_PREFIX = "__BROWSER__::";
|
|
12280
|
+
// GH #540: the agent edited a file whose language has a server gu could use — offer it.
|
|
12281
|
+
const LSP_PREFIX = "__LSP__::";
|
|
11860
12282
|
// How long the browser question waits before "Yes, this time" (GH #411).
|
|
11861
12283
|
const BROWSER_APPROVAL_MS = 10_000;
|
|
11862
12284
|
async function approvalPrompt(command) {
|
|
@@ -11916,6 +12338,42 @@ async function approvalPrompt(command) {
|
|
|
11916
12338
|
);
|
|
11917
12339
|
return { allow: idx === 0, dontAsk: false };
|
|
11918
12340
|
}
|
|
12341
|
+
if (command.startsWith(LSP_PREFIX)) {
|
|
12342
|
+
// Claude Code's rules: Yes / Not now / Never for this language / Never ask; no answer in 30 s
|
|
12343
|
+
// counts as ignored, and after 5 ignored offers gu stops offering. Every answer is saved here —
|
|
12344
|
+
// the worker's host only reads the file. Only "Yes" lets the agent go on to use it now.
|
|
12345
|
+
const [id = "", name = "", server = "", how = "", size = ""] = command.slice(LSP_PREFIX.length).split("\t");
|
|
12346
|
+
const lang = lspById(id, allLanguages({ home: homedir(), workspace: resolve(process.cwd()) }));
|
|
12347
|
+
if (!lang || !process.stdin.isTTY) return { allow: false, dontAsk: false };
|
|
12348
|
+
const needsInstall = how === "install";
|
|
12349
|
+
const where = lang.custom
|
|
12350
|
+
// A project's lsp.json names a program to run — say exactly which, and from which file, so a
|
|
12351
|
+
// cloned repo cannot start something unseen (GH #542).
|
|
12352
|
+
? ` It runs: ${[lang.command, ...lang.args].join(" ")} (set in ${lang.source.replace(homedir(), "~")}).`
|
|
12353
|
+
: !needsInstall
|
|
12354
|
+
? " It is already on this computer — nothing to download."
|
|
12355
|
+
: lang.tool
|
|
12356
|
+
? ` gu runs \`${lang.tool.what}\` (${size || lang.size}). It is open source (${lang.licence}).`
|
|
12357
|
+
: ` gu installs it from npm (${size || lang.size}, into ~/.gonext/lsp — no admin rights). It is open source (${lang.licence}).`;
|
|
12358
|
+
process.stdout.write(
|
|
12359
|
+
// GH #554: on the gutter like every other line of the turn — it sat two columns to the left.
|
|
12360
|
+
"\n" + GUTTER + accent(`${name} code intelligence`) + dim(` (no answer in ${LSP_OFFER_MS / 1000}s = not now)`) + "\n" +
|
|
12361
|
+
wrapGutter(
|
|
12362
|
+
`The agent just edited a ${name} file. With ${server} (a language server) it sees compile and type errors right after each edit and fixes them before it says it is done.` + where,
|
|
12363
|
+
dim,
|
|
12364
|
+
) + "\n",
|
|
12365
|
+
);
|
|
12366
|
+
const idx = await pickFromList(offerRows(lang, { needsInstall }), 0, { timeoutMs: LSP_OFFER_MS, timeoutIndex: -2 });
|
|
12367
|
+
const choice = idx === -2 ? "ignored" : OFFER_CHOICES[idx] ?? "not-now";
|
|
12368
|
+
saveLspState(applyOfferAnswer(loadLspState(), id, choice));
|
|
12369
|
+
const said = {
|
|
12370
|
+
yes: needsInstall ? `installing ${server} — errors are checked from the next edit. /lsp shows it.` : `${name} code intelligence is on. /lsp turns it off.`,
|
|
12371
|
+
never: `won't offer ${name} again — /lsp turns it on.`,
|
|
12372
|
+
"never-ask": "won't offer language servers again — /lsp turns one on.",
|
|
12373
|
+
}[choice];
|
|
12374
|
+
if (said) process.stdout.write(GUTTER + dim(said) + "\n");
|
|
12375
|
+
return { allow: choice === "yes", dontAsk: false };
|
|
12376
|
+
}
|
|
11919
12377
|
if (command.startsWith(BROWSER_PREFIX)) {
|
|
11920
12378
|
const [folder = "", what = ""] = command.slice(BROWSER_PREFIX.length).split("\t");
|
|
11921
12379
|
if (!process.stdin.isTTY) return { allow: false, dontAsk: false };
|
|
@@ -13933,6 +14391,7 @@ async function runAgentTurn(history, { attachJobId = "", ownJob = false } = {})
|
|
|
13933
14391
|
// GH #514: the agent just read what was typed — it becomes part of the history HERE, between its steps.
|
|
13934
14392
|
if (line.startsWith(USERNOTE_PREFIX)) {
|
|
13935
14393
|
const taken = waitingNotes.splice(0, parseUserNote(line));
|
|
14394
|
+
if (!waitingNotes.length) sendNowPending = false; // GH #560
|
|
13936
14395
|
if (taken.length) {
|
|
13937
14396
|
readNotes.push(...taken.map((n) => n.text));
|
|
13938
14397
|
const unseen = taken.filter((n) => !n.shown);
|
|
@@ -13946,6 +14405,21 @@ async function runAgentTurn(history, { attachJobId = "", ownJob = false } = {})
|
|
|
13946
14405
|
lastContentAt = Date.now();
|
|
13947
14406
|
continue;
|
|
13948
14407
|
}
|
|
14408
|
+
// GH #562: the agent answered, in one line, what was typed during the turn — normal text, under that message.
|
|
14409
|
+
if (line.startsWith(SAY_PREFIX)) {
|
|
14410
|
+
const said = parseSay(line);
|
|
14411
|
+
if (said) {
|
|
14412
|
+
releaseHeldThought();
|
|
14413
|
+
onContent();
|
|
14414
|
+
// The answer's own shape: wrapped at the text column, the ● hanging in the gutter on its first row.
|
|
14415
|
+
const rows = wrapBlock(said, GUTTER, process.stdout.columns || 80).map((l) => renderMdBold(l));
|
|
14416
|
+
const block = rows.map((l, i) => (i === 0 ? markLine("●") : GUTTER) + l).join("\n");
|
|
14417
|
+
process.stdout.write((lastWasBlank ? "" : "\n") + block + "\n\n");
|
|
14418
|
+
lastWasBlank = true;
|
|
14419
|
+
}
|
|
14420
|
+
lastContentAt = Date.now();
|
|
14421
|
+
continue;
|
|
14422
|
+
}
|
|
13949
14423
|
if (line.startsWith(MODELFALLBACK_PREFIX)) {
|
|
13950
14424
|
const fb = parseModelFallback(line);
|
|
13951
14425
|
if (fb) {
|
|
@@ -14597,6 +15071,7 @@ async function runAgentTurn(history, { attachJobId = "", ownJob = false } = {})
|
|
|
14597
15071
|
}
|
|
14598
15072
|
currentJobId = null;
|
|
14599
15073
|
waitingNotes = [];
|
|
15074
|
+
sendNowPending = false;
|
|
14600
15075
|
// Drop anything typed (but not submitted) during the turn — echo was muted, so it's
|
|
14601
15076
|
// invisible; without this it would surface on the next prompt.
|
|
14602
15077
|
rl.line = "";
|
|
@@ -15433,15 +15908,28 @@ async function main() {
|
|
|
15433
15908
|
// anyway: one is already bound to the port. On loopback a 15s wait rather than an
|
|
15434
15909
|
// instant refusal almost always means the API is up but stuck on MongoDB.
|
|
15435
15910
|
const hung = isTimeout(err);
|
|
15911
|
+
// Name the storage this computer actually uses (GH #557 follow-up): a gudb computer has no
|
|
15912
|
+
// MongoDB, and telling its owner to look at one sends them after a program they never had.
|
|
15913
|
+
let onGudb = false;
|
|
15914
|
+
try {
|
|
15915
|
+
const { readLocalDb } = await import("./client-expert-api.mjs");
|
|
15916
|
+
onGudb = readLocalDb() === "gudb";
|
|
15917
|
+
} catch {
|
|
15918
|
+
/* unknown — say MongoDB, as before */
|
|
15919
|
+
}
|
|
15436
15920
|
console.error(
|
|
15437
15921
|
red("gu: the local API " + (hung ? "is not answering on " : "isn't running on ") + apiBase + ".") +
|
|
15438
|
-
dim(
|
|
15439
|
-
|
|
15922
|
+
dim(
|
|
15923
|
+
onGudb
|
|
15924
|
+
? "\n Local mode keeps your conversations in a database file on this machine, and"
|
|
15925
|
+
: "\n Local mode keeps your conversations in MongoDB on this machine, and that"
|
|
15926
|
+
) +
|
|
15927
|
+
dim(onGudb ? "\n that API is what reads it. It does not survive a reboot on its own.\n" : "\n API is what reads it. It does not survive a reboot on its own.\n")
|
|
15440
15928
|
);
|
|
15441
15929
|
// ASK MONGODB ITSELF before telling the reader to (task #329). It can die AFTER the startup
|
|
15442
15930
|
// check passed, and "is mongod running?" is a question this process answers in milliseconds.
|
|
15443
15931
|
let mongoDown = "";
|
|
15444
|
-
if (hung) {
|
|
15932
|
+
if (hung && !onGudb) {
|
|
15445
15933
|
try {
|
|
15446
15934
|
const { localMongoDown } = await import("./client-expert-run.mjs");
|
|
15447
15935
|
const { localMongoUri } = await import("./client-expert-api.mjs");
|
|
@@ -15460,11 +15948,11 @@ async function main() {
|
|
|
15460
15948
|
// Do NOT try to start it — the port is taken by the process that is failing to answer.
|
|
15461
15949
|
console.error(
|
|
15462
15950
|
dim(" Something IS listening there but did not reply within ") +
|
|
15463
|
-
dim(`${API_CALL_TIMEOUT_MS / 1000}s, so the API is running and stuck
|
|
15464
|
-
dim("\n usually on MongoDB. Check, in this order:") +
|
|
15951
|
+
dim(`${API_CALL_TIMEOUT_MS / 1000}s, so the API is running and stuck` + (onGudb ? "." : " —")) +
|
|
15952
|
+
dim(onGudb ? "\n Check, in this order:" : "\n usually on MongoDB. Check, in this order:") +
|
|
15465
15953
|
dim("\n gu-cli api status does it answer at all?") +
|
|
15466
15954
|
dim("\n ~/.gonext/local-api.log what it was doing when it stopped answering") +
|
|
15467
|
-
dim("\n is mongod running? the API waits on it and never times out itself") +
|
|
15955
|
+
(onGudb ? "" : dim("\n is mongod running? the API waits on it and never times out itself")) +
|
|
15468
15956
|
dim("\n Then restart it: gu-cli api stop && gu-cli api start\n")
|
|
15469
15957
|
);
|
|
15470
15958
|
} else {
|
|
@@ -15506,6 +15994,7 @@ async function main() {
|
|
|
15506
15994
|
}
|
|
15507
15995
|
delete process.env.GU_API_REOPENED; // GH #397: started — the next start may re-open again
|
|
15508
15996
|
console.log(wrapGutter("Ask about this repo. Type / to see commands (Tab completes). Ctrl-C aborts a running turn.", dim) + "\n");
|
|
15997
|
+
await askAutocompactOnce(); // GH #538: once per computer — no answer means 400k, all models
|
|
15509
15998
|
// #221: gu runs, but its own npm folder is not on PATH (npm skipped the postinstall that adds it).
|
|
15510
15999
|
try {
|
|
15511
16000
|
const { pathNoticeLine } = await import("./env-check.mjs");
|
|
@@ -15749,6 +16238,7 @@ async function main() {
|
|
|
15749
16238
|
if (turnQueue.size > 0 && _lineQueue.length === 0) _lineQueue.push(turnQueue.shift());
|
|
15750
16239
|
for (;;) {
|
|
15751
16240
|
lineRaw = await nextLine();
|
|
16241
|
+
clearNextHint(); // GH #536: whatever was sent, the suggestion was for the moment before it
|
|
15752
16242
|
const echoed = enterEchoed;
|
|
15753
16243
|
enterEchoed = false;
|
|
15754
16244
|
if (lineRaw === null || lineRaw.trim()) break;
|
|
@@ -15868,6 +16358,30 @@ async function main() {
|
|
|
15868
16358
|
printCommands();
|
|
15869
16359
|
continue;
|
|
15870
16360
|
}
|
|
16361
|
+
if (line === "/lsp" || line.startsWith("/lsp ")) {
|
|
16362
|
+
await lspCommand(line.slice("/lsp".length));
|
|
16363
|
+
continue;
|
|
16364
|
+
}
|
|
16365
|
+
if (line === "/autocompact" || line.startsWith("/autocompact ")) {
|
|
16366
|
+
await autocompactCommand(line.slice("/autocompact".length));
|
|
16367
|
+
continue;
|
|
16368
|
+
}
|
|
16369
|
+
if (line === "/suggestions" || line.startsWith("/suggestions ")) {
|
|
16370
|
+
// GH #536: the suggested next message after a turn — on by default, remembered for every folder.
|
|
16371
|
+
suggestionsOn = suggestionsToggle(line.slice("/suggestions".length), suggestionsOn);
|
|
16372
|
+
try {
|
|
16373
|
+
mkdirSync(dirname(SUGGESTIONS_FILE), { recursive: true });
|
|
16374
|
+
writeFileSync(SUGGESTIONS_FILE, suggestionsOn ? "on\n" : "off\n");
|
|
16375
|
+
} catch {}
|
|
16376
|
+
if (!suggestionsOn) clearNextHint();
|
|
16377
|
+
console.log(
|
|
16378
|
+
GUTTER + (suggestionsOn ? accent("suggestions: ON") : dim("suggestions: OFF")) +
|
|
16379
|
+
dim(suggestionsOn
|
|
16380
|
+
? " — after some answers a next message appears in the input; Tab takes it.\n"
|
|
16381
|
+
: " — no suggested next message after a turn. /suggestions on brings it back.\n")
|
|
16382
|
+
);
|
|
16383
|
+
continue;
|
|
16384
|
+
}
|
|
15871
16385
|
if (line === "/hover") {
|
|
15872
16386
|
// Mouse hover/click on the thinking line (#96) vs. scrolling during a turn: the terminal
|
|
15873
16387
|
// only reports wheel events to US when mouse tracking is on, so they're exclusive. Off by
|
|
@@ -16446,6 +16960,8 @@ async function main() {
|
|
|
16446
16960
|
// #343: the turn's own record of the fallback, under its answer — the bar's row can be
|
|
16447
16961
|
// gone by the next turn, and the scrollback is where "which model wrote this?" is asked.
|
|
16448
16962
|
if (fellBack) printFallbackLine(fellBack);
|
|
16963
|
+
// GH #536: maybe a suggested next message — not when a queued question runs next anyway.
|
|
16964
|
+
if (turnQueue.size === 0 && _lineQueue.length === 0) offerNextHint(taskLine, answer);
|
|
16449
16965
|
} else {
|
|
16450
16966
|
// A turn that ended WITHOUT an answer (Ctrl+C cancel, or an abort/failure) must not
|
|
16451
16967
|
// silently launch another turn. Any keystrokes the user typed DURING the dead turn
|