@tiens.nguyen/gu-cli 1.0.940 → 1.0.942

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/gu-repl.mjs CHANGED
@@ -80,12 +80,15 @@ import {
80
80
  createMouseReportReader,
81
81
  stripLeakedMouseReports,
82
82
  agentPickerItems,
83
+ agentsPanelRows,
83
84
  agentsIndicator,
84
85
  classifyCliArg,
85
86
  maskKey,
86
87
  otherAgentRows,
87
88
  updateRow,
88
89
  noticeRow,
90
+ midTurnCommandKind,
91
+ HIDDEN_COMMANDS,
89
92
  updateNotice,
90
93
  answerBlock,
91
94
  updateRestartNote,
@@ -149,6 +152,7 @@ import {
149
152
  import { completedFlush, splitLiveStream } from "./completed-flush.mjs";
150
153
  import { isScaffoldStep, isGroupableStep, stepGroupRows, stepRowSpans, relativizePaths } from "./step-group.mjs";
151
154
  import { clearLogsNoticeText } from "./clear-logs.mjs";
155
+ import { gudbNotice as gudbNoticeSync, lowDiskNotice } from "./gudb-size.mjs"; // GH #594, #597
152
156
  import { commandAllowedIn, commandAllowProject, commandAllowSource, commandForget, commandProjectAllowed, sourcedFileOf, PROJECT_CHOICE } from "./command-allow.mjs";
153
157
  import { allowIn, allowedIn, bridgeCommand, browserReport, bridgeStatus, extensionDir, findDevInstalls, helpInstall, installExtensionFiles, installSteps, localLeftovers, openExtensionsPage, removeLocalFiles, STORE_URL, stopBridge } from "./browser-command.mjs";
154
158
  import { commandLogFile, killShell, logTail, markAnnounced, readShells, recapQuestion, runningShells, shellsToRecap, statusText as shellStatusText, renderShellDetails, shellPanelRows, shellPickerLabel, shellState, shellsNotice } from "./shell-details.mjs";
@@ -156,7 +160,8 @@ import { discoverSkills, matchSkillCommand } from "./skills.mjs";
156
160
  import { appendNew, archivePathFor, archivedWorkspaceKey, markReset, seedArchive } from "./conversation-archive.mjs";
157
161
  import { addAllowRule, listServers as listMcpServers } from "./mcp-config.mjs";
158
162
  import { unapprovedProjectServers } from "./mcp-command.mjs";
159
- import { readHooks } from "./hooks-config.mjs";
163
+ import { readHooks, hooksForTurn, sessionForTurn } from "./hooks-config.mjs";
164
+ import { memoryRuntime, currentTask, setTask, memoryBarText, taskPickerLabels } from "./memory-task.mjs"; // GH #595
160
165
  import { readSkillSource, sourceLabel, SKILL_SOURCE_KEY } from "./skill-source.mjs";
161
166
  import { codingBannerLabel, isOllamaCloudUrl, SECRET_KEY_HINT } from "./coding-key-prompt.mjs";
162
167
  import { questionEchoText, thoughtPrintSeq, wrapDiffText } from "./terminal-layout.mjs";
@@ -693,7 +698,7 @@ if (cliVerdict.kind === "run") {
693
698
  } else if (argv.includes("--help") || argv.includes("-h")) {
694
699
  console.log(
695
700
  "gu — terminal agent REPL for the current folder\n\n" +
696
- "Usage: gu [-v|--verbose] [--log] [--color] [--name <text>] [--license <pro token>]\n" +
701
+ "Usage: gu [-v|--verbose] [--log] [--color] [--name <text>] [--license <pro token>] [--cloud <code>]\n" +
697
702
  " gu status # worker + a table of the running model servers\n" +
698
703
  " gu start|stop|restart|logs # manage the background worker\n" +
699
704
  " gu logs <port|pid> [-f] # tail a running model server's log\n" +
@@ -709,6 +714,8 @@ if (cliVerdict.kind === "run") {
709
714
  " --license <token> pro license: a first install ASKS how this machine runs (hosted\n" +
710
715
  " client / MLX host / private). Without it, a first install is\n" +
711
716
  " private by default — the whole stack on this machine.\n" +
717
+ " --cloud <code> a Cloud link someone sent you (gucli.com/cloud/<code>): this\n" +
718
+ " computer uses Cloud mode, and the link is added to your account.\n" +
712
719
  " -h, --help this help\n\n" +
713
720
  "Auth comes from ~/.gu/worker.env; models/budgets/RAG come from your web Settings.\n" +
714
721
  "Inside the REPL: /exit · /model · /new · /help — Ctrl-C stops following a turn.\n" +
@@ -921,7 +928,7 @@ if (!workerKey || !apiBase) {
921
928
  const {
922
929
  probeMachine, askMode, runClientExpertSetup, loadState, saveState,
923
930
  } = await import("./client-expert-run.mjs");
924
- const { clientExpertAvailable, parseLicenseFlag, resolveFirstRunMode, licenseUnverifiedLine, promptForLicenseToken } =
931
+ const { clientExpertAvailable, parseLicenseFlag, resolveFirstRunMode, licenseUnverifiedLine, promptForLicenseToken, parseCloudFlag, checkCloudLink } =
925
932
  await import("./client-expert-setup.mjs");
926
933
  const machine0 = await probeMachine();
927
934
  const gate0 = clientExpertAvailable({ workerEnvExists: false, ...machine0 });
@@ -931,9 +938,12 @@ if (!workerKey || !apiBase) {
931
938
  // three-way menu (hosted client / MLX host / private) is shown only when the run
932
939
  // carries a pro license token: `gu --license <token>`.
933
940
  const licenseToken0 = parseLicenseFlag(argv);
941
+ // GH #603: `gu --cloud <code>` — an admin's Cloud link: Cloud mode, no menu (checked first).
942
+ const cloudCode0 = await cloudLinkForFirstRun(parseCloudFlag(argv), checkCloudLink);
934
943
  let plan0 = resolveFirstRunMode({
935
944
  licenseToken: licenseToken0,
936
945
  expertAvailable: gate0.available,
946
+ cloudCode: cloudCode0,
937
947
  });
938
948
  if (plan0.ask) {
939
949
  // A bad token no longer picks private FOR the user: warn, and let them paste another
@@ -1143,6 +1153,7 @@ const COMMANDS = [
1143
1153
  { name: "/tokens", desc: "break down the last prompt sent to the coding model — how much of it was RAG" },
1144
1154
  { name: "/voucher", usage: "/voucher CODE", desc: "use a voucher code — free days for this computer's trial or your free account, or a free model allowance" },
1145
1155
  { name: "/support", desc: "send the gu support team a request with gu's logs attached (secrets masked) — shows what goes first, then asks" },
1156
+ { name: "/backup-db", desc: "back up gu's built-in database safely (SQLite's own backup, consistent while gu runs) — keeps the last 3" },
1146
1157
  { name: "/clear-logs", desc: "show what gu's logs, RAG indexes and old API versions take on disk, then ask what to clear — the logs first" },
1147
1158
  { name: "/cost", usage: "/cost [all]", desc: "what this session and the last turn cost, and the price of the model in use — \"all\" shows every price (prices update by themselves)" },
1148
1159
  // ONE name, /new (user, #278). /reset and /clear still work (HIDDEN_COMMANDS) for habit and
@@ -1151,6 +1162,7 @@ const COMMANDS = [
1151
1162
  { name: "/hooks", usage: "/hooks [list|approve|unapprove]", desc: "hooks: commands gu runs on onStart, onAsk, onToolDone, onTurnEnd — list them, approve this project's" },
1152
1163
  { name: "/mcp", usage: "/mcp [list|tools|add|remove|enable|disable|approve|allow|disallow|reconnect]", desc: "MCP servers: see which connect, add one (asks step by step), choose which tools run without asking" },
1153
1164
  { name: "/switch-skill", usage: "/switch-skill [claude|gu]", desc: "whose skills, MCP servers and hooks this folder uses — Claude Code's (.claude) or gu's own (.gu)" },
1165
+ { name: "/task", desc: "choose the task the memory skill records this session's work under (shown at the bottom)" },
1154
1166
  { name: "/resume", desc: "carry on the last unfinished task in this folder — Claude Code's or gu's — from where it stopped (memory skill)" },
1155
1167
  { name: "/skill-pack", usage: "/skill-pack <name> [--out <file>] [--runtime <dir>]", desc: "pack a skill (gu's or Claude's) with its MCP servers, hooks and code into one zip for another machine" },
1156
1168
  { name: "/skill-install", usage: "/skill-install <zip|folder> [--gu] [--claude] [--dry-run]", desc: "install a packed skill for gu and Claude Code (whichever is set up here)" },
@@ -1813,6 +1825,16 @@ function applyClick({ row, col }) {
1813
1825
  void runLimitsSeen();
1814
1826
  return;
1815
1827
  }
1828
+ if (diskRowTarget && row === updateRowAbs &&
1829
+ col - 1 >= diskRowTarget.from && col - 1 < diskRowTarget.to) {
1830
+ void runClearLogs(); // what gu itself can free
1831
+ return;
1832
+ }
1833
+ if (gudbRowTarget && row === updateRowAbs &&
1834
+ col - 1 >= gudbRowTarget.from && col - 1 < gudbRowTarget.to) {
1835
+ void runCleanOldData(); // GH #594: one click, no questions
1836
+ return;
1837
+ }
1816
1838
  if (logsRowTarget && row === updateRowAbs &&
1817
1839
  col - 1 >= logsRowTarget.from && col - 1 < logsRowTarget.to) {
1818
1840
  void runClearLogs();
@@ -2541,6 +2563,30 @@ rl.on("line", (l) => {
2541
2563
  imageStore.clear();
2542
2564
  typedDuringTurn = false;
2543
2565
  turnTyping.reset();
2566
+ // GH #588: /model during a turn opens the picker NOW — it used to go to the agent as a note.
2567
+ // The running job carries its own coder (its payload), so the choice is for the next turn.
2568
+ if (/^\/models?$/i.test(queued)) {
2569
+ void chooseModelDuringTurn();
2570
+ return;
2571
+ }
2572
+ // GH #595: /task mid-turn — the rest of this turn's steps are filed under the chosen task.
2573
+ if (/^\/tasks?$/i.test(queued)) {
2574
+ void runTaskCommand();
2575
+ return;
2576
+ }
2577
+ // GH #593: any other gu command never goes to the agent as a note — it runs now, or after the turn.
2578
+ const cmdKind = midTurnCommandKind(queued, knownCommandWords());
2579
+ if (cmdKind === "now") {
2580
+ void runCommandDuringTurn(queued);
2581
+ return;
2582
+ }
2583
+ if (cmdKind === "after") {
2584
+ if (turnQueue.push(queued)) {
2585
+ console.log(GUTTER + dim(`${queued.split(/\s+/)[0]} runs when this turn ends.`));
2586
+ if (barPinned()) paintBar();
2587
+ } else process.stdout.write(dim(`\n (${turnQueue.size} questions are already queued — wait for one to run)\n`));
2588
+ return;
2589
+ }
2544
2590
  // GH #506: with a running job, the text goes to the agent's NEXT step (appended after the
2545
2591
  // current step's result — cache-safe). Not read by the end of the turn = the next question.
2546
2592
  // GH #514: like chat — no notices. Pinned, it waits as a ">> " row above the input box until the agent
@@ -2826,9 +2872,191 @@ function slashCloseSeq(line, cursor, cols) {
2826
2872
  // so the bar reflects it and Shift+Tab cycles it; wiring it to actually gate the agent's
2827
2873
  // edits is a deliberate follow-up.
2828
2874
  let editMode = "accept"; // "accept" | "manual"
2829
- const modeLineText = () =>
2830
- white("✎ " + (editMode === "accept" ? "accept edits on" : "manually edit")) +
2831
- dim(" (shift+tab to switch)") + (quickBarHint(quickModels) ? dim(" " + quickBarHint(quickModels)) : "");
2875
+ const modeLineText = () => {
2876
+ const base = white("✎ " + (editMode === "accept" ? "accept edits on" : "manually edit")) + dim(" (shift+tab to switch)");
2877
+ const quick = quickBarHint(quickModels) ? dim(" " + quickBarHint(quickModels)) : "";
2878
+ // GH #595: the task the memory skill files this session's work under — yellow when it is only the
2879
+ // project's newest open task (not chosen for this session): that is how work gets misfiled.
2880
+ const width = Math.max(20, process.stdout.columns || 80) - GUTTER.length - 1;
2881
+ const room = width - visibleLen(base) - 3;
2882
+ const mem = memoryBarText(memCurrent, Math.min(room, 80), memSkills);
2883
+ if (!mem.text || room < 16) return base + quick;
2884
+ const memPart = " " + (mem.warn ? yellow(mem.text) : dim(mem.text));
2885
+ return base + memPart + (visibleLen(base + memPart + quick) <= width ? quick : "");
2886
+ };
2887
+ // GH #595: the memory skill's current task for this session (null = no memory here / not installed for gu).
2888
+ let memCurrent = null;
2889
+ let memRuntimeFound = null;
2890
+ // Whose skills this folder uses (/switch-skill) and whether the memory skill is in them / in the other set.
2891
+ let memSkills = { label: "", active: false, otherHas: false };
2892
+ async function refreshMemoryTask() {
2893
+ try {
2894
+ const cwd = resolve(process.cwd());
2895
+ const { readSkillSource, sourceLabel } = await import("./skill-source.mjs");
2896
+ const source = readSkillSource(cwd);
2897
+ memRuntimeFound = memoryRuntime(hooksForTurn({ cwd, source }));
2898
+ const other = memoryRuntime(hooksForTurn({ cwd, source: source === "claude" ? "gu" : "claude" }));
2899
+ const skills = { label: sourceLabel(source), active: Boolean(memRuntimeFound), otherHas: Boolean(other) };
2900
+ const next = memRuntimeFound ? await currentTask({ runtime: memRuntimeFound, cwd, session: sessionForTurn(cwd)?.id ?? "" }) : null;
2901
+ const changed = JSON.stringify([next?.task ?? null, next?.chosen, skills]) !== JSON.stringify([memCurrent?.task ?? null, memCurrent?.chosen, memSkills]);
2902
+ memSkills = skills;
2903
+ memCurrent = next;
2904
+ if (changed && barPinned()) paintBar();
2905
+ } catch {
2906
+ /* the bar just says nothing about memory */
2907
+ }
2908
+ }
2909
+ /**
2910
+ * /task (GH #595): choose the task the memory files this session's work under. The list is the
2911
+ * project's open tasks, newest first, the current one marked.
2912
+ */
2913
+ /**
2914
+ * GH #603: a first run started with `gu --cloud <code>`. The link is checked before anything is set
2915
+ * up — a removed or mistyped one says why and the run goes on as if no flag was given. → the code, or "".
2916
+ */
2917
+ async function cloudLinkForFirstRun(code, checkCloudLink) {
2918
+ if (!code) return "";
2919
+ const { DEFAULT_API_BASE } = await import("./device-login.mjs");
2920
+ const hostedBase = String(process.env.GU_TOKEN_API_BASE ?? "").trim() || DEFAULT_API_BASE;
2921
+ const c = await checkCloudLink(code, { hostedBase });
2922
+ if (!c.ok) {
2923
+ console.log("\n" + GUTTER + yellow(c.why));
2924
+ return "";
2925
+ }
2926
+ console.log(
2927
+ "\n" + GUTTER + accent(`Cloud link ${code}`) +
2928
+ dim(` — this computer uses Cloud mode${c.email ? `; sign in with ${c.email}` : ""}.`)
2929
+ );
2930
+ return code;
2931
+ }
2932
+
2933
+ /**
2934
+ * GH #603: after sign-in, `gu --cloud <code>` puts the link on this account (the API checks it is the
2935
+ * email the admin typed). Says what happened in one line; never stops gu from starting.
2936
+ */
2937
+ async function claimCloudLinkIfAsked() {
2938
+ try {
2939
+ const { parseCloudFlag } = await import("./client-expert-setup.mjs");
2940
+ const code = parseCloudFlag(argv);
2941
+ if (!code) return;
2942
+ const { loadState } = await import("./client-expert-run.mjs");
2943
+ const st = await loadState();
2944
+ if (st.chosenMode === "client-expert" || isClientExpert()) {
2945
+ console.log(GUTTER + yellow(`This computer runs in private mode, so the Cloud link ${code} doesn't apply here.`) +
2946
+ dim(` To switch: gu clear, then gu --cloud ${code}`));
2947
+ return;
2948
+ }
2949
+ if (!workerKey) {
2950
+ console.log(GUTTER + yellow(`Cloud link ${code}: gu isn't signed in yet, so it couldn't be added.`) + dim(` Run gu --cloud ${code} again after signing in.`));
2951
+ return;
2952
+ }
2953
+ const r = await fetch(`${apiBase}/api/worker/cloud-link/claim`, {
2954
+ method: "POST",
2955
+ headers: { "Content-Type": "application/json", "X-Worker-Key": workerKey },
2956
+ body: JSON.stringify({ code }),
2957
+ signal: AbortSignal.timeout(15_000),
2958
+ });
2959
+ const body = await r.json().catch(() => ({}));
2960
+ if (r.ok) console.log(GUTTER + accent(`✓ Cloud link ${code} is on this account`) + dim(" — Cloud mode is ready.\n"));
2961
+ else console.log(GUTTER + yellow(body?.error || `Cloud link ${code} could not be added (HTTP ${r.status}).`) + "\n");
2962
+ } catch (e) {
2963
+ console.log(GUTTER + dim(`Cloud link: could not reach the server (${e instanceof Error ? e.message : e}). Run the same command again later.`));
2964
+ }
2965
+ }
2966
+
2967
+ /** GH #536 / #593: /suggestions [on|off] — at the prompt or during a turn. */
2968
+ function setSuggestions(arg) {
2969
+ // GH #536: the suggested next message after a turn — on by default, remembered for every folder.
2970
+ suggestionsOn = suggestionsToggle(arg, suggestionsOn);
2971
+ try {
2972
+ mkdirSync(dirname(SUGGESTIONS_FILE), { recursive: true });
2973
+ writeFileSync(SUGGESTIONS_FILE, suggestionsOn ? "on\n" : "off\n");
2974
+ } catch {}
2975
+ if (!suggestionsOn) clearNextHint();
2976
+ console.log(
2977
+ GUTTER + (suggestionsOn ? accent("suggestions: ON") : dim("suggestions: OFF")) +
2978
+ dim(suggestionsOn
2979
+ ? " — after some answers a next message appears in the input; Tab takes it.\n"
2980
+ : " — no suggested next message after a turn. /suggestions on brings it back.\n")
2981
+ );
2982
+ }
2983
+
2984
+ /** GH #593: /budget — the short terminal version of web-v2's /providers budgets (#205). The server
2985
+ * judges Pro, the account email and "has items" (api/src/providers/terminalBudget.ts). */
2986
+ async function showBudget() {
2987
+ try {
2988
+ const bv = await import("./budget-view.mjs");
2989
+ const ct = await import("./cli-token.mjs");
2990
+ const { DEFAULT_API_BASE } = await import("./device-login.mjs");
2991
+ const state = await ct.readState(join(homedir(), ".gu"));
2992
+ const result = await bv.fetchProvidersBudget({
2993
+ apiBase,
2994
+ workerKey,
2995
+ hostedBase: String(process.env.GU_TOKEN_API_BASE ?? "").trim() || DEFAULT_API_BASE,
2996
+ token: state.token,
2997
+ });
2998
+ const out = bv.budgetLines(result, { site: ct.siteUrl() });
2999
+ for (const l of out.lines) console.log(GUTTER + (out.tone === "ok" ? l : dim(l)));
3000
+ console.log("");
3001
+ } catch (e) {
3002
+ console.log(GUTTER + dim(`Could not show your budgets: ${e instanceof Error ? e.message : e}\n`));
3003
+ }
3004
+ }
3005
+
3006
+ /** GH #593: the words gu answers to as commands — listed, aliases and hidden. */
3007
+ function knownCommandWords() {
3008
+ return [...COMMANDS.flatMap((c) => [c.name, ...(c.aliases ?? [])]), ...HIDDEN_COMMANDS].map((w) => w.toLowerCase());
3009
+ }
3010
+
3011
+ /** GH #593: a command that only SHOWS something, typed during a turn — runs now; the turn goes on. */
3012
+ async function runCommandDuringTurn(line) {
3013
+ const word = line.split(/\s+/)[0].toLowerCase();
3014
+ try {
3015
+ if (word === "/" || word === "/help") printCommands();
3016
+ else if (word === "/cost" || word === "/prices") await runCostCommand(line);
3017
+ else if (word === "/shells") await showShells();
3018
+ else if (word === "/budget") await showBudget();
3019
+ else if (word === "/mcp") await runMcpSlashCommand(line);
3020
+ else if (word === "/hooks") {
3021
+ const { runHooksCommand } = await import("./hooks-command.mjs");
3022
+ const style = { ok: accent, warn: yellow, dim };
3023
+ await runHooksCommand([], { cwd: process.cwd(), print: (l, kind) => console.log(GUTTER + (style[kind] ?? ((x) => x))(l)) });
3024
+ console.log("");
3025
+ } else if (word === "/suggestions") setSuggestions(line.slice("/suggestions".length));
3026
+ } catch (e) {
3027
+ console.log(GUTTER + dim(`${word}: ${e instanceof Error ? e.message : e}`));
3028
+ }
3029
+ if (barPinned()) paintBar();
3030
+ }
3031
+
3032
+ async function runTaskCommand() {
3033
+ if (listPickerActive || approvalActive) return;
3034
+ await refreshMemoryTask();
3035
+ if (!memRuntimeFound) {
3036
+ console.log("\n" + GUTTER + dim("The memory skill isn't installed for gu — /skills shows how to add it.") + "\n");
3037
+ return;
3038
+ }
3039
+ if (!memCurrent?.open?.length) {
3040
+ console.log("\n" + GUTTER + dim("No open tasks in this project's memory. Ask gu to create one (\"create a task …\").") + "\n");
3041
+ return;
3042
+ }
3043
+ const width = Math.max(20, process.stdout.columns || 80);
3044
+ console.log("");
3045
+ console.log(dim(` Record this session's work under which task? (${PICK_HINT}):`));
3046
+ const at = memCurrent.open.findIndex((t) => t.id === memCurrent.task?.id);
3047
+ const pick = await pickFromList(taskPickerLabels(memCurrent, width), Math.max(0, at));
3048
+ if (pick < 0) {
3049
+ console.log(dim(" (cancelled)\n"));
3050
+ paintBar();
3051
+ return;
3052
+ }
3053
+ const cwd = resolve(process.cwd());
3054
+ const t = await setTask({ runtime: memRuntimeFound, cwd, session: sessionForTurn(cwd)?.id ?? "", id: memCurrent.open[pick].id });
3055
+ if (t) console.log(GUTTER + accent(`✓ this session's work is recorded under #${t.id} ${t.title}`) + "\n");
3056
+ else console.log(GUTTER + red("couldn't switch the task — the memory skill didn't answer") + "\n");
3057
+ await refreshMemoryTask();
3058
+ paintBar();
3059
+ }
2832
3060
  // Token usage for the bar's middle row (task #104): the LAST turn's code-model input +
2833
3061
  // output, then the coder's lifetime output total. Unlike the old per-turn print, this row is
2834
3062
  // ALWAYS on screen — a turn that did no code-model work honestly reads "0", and the lifetime
@@ -3548,17 +3776,35 @@ function zoneNotice(width) {
3548
3776
  // While the token question is open it is the ONLY thing on the screen (#222): the housekeeping
3549
3777
  // notices (new prices, new token limits) wait, and the token notice would repeat the question.
3550
3778
  if (limitsUpdate && !tokenQuestionOpen) items.push({ key: "limits", clickable: true, paint: accent, text: `${limitsUpdate.label} (click)` });
3551
- if (tokenNotice?.text && !tokenQuestionOpen) items.push({ key: "token", paint: tokenNotice.urgent ? yellow : dim, text: tokenNotice.text });
3779
+ // GH #602: the gu token notice ("trial · 417 days left · …") is NOT here any more — it has a row of its
3780
+ // own below this one (zoneTokenRow), so neither is squeezed or dropped for the other.
3552
3781
  const agents = agentsIndicator(otherAgents);
3553
3782
  if (agents) items.push({ key: "agents", clickable: true, paint: accent, text: `${agents} running (click)` });
3554
3783
  const shells = shellsNotice(shellEntries, { cwd: process.cwd() });
3555
3784
  if (shells) items.push({ key: "shells", clickable: true, paint: shells.tone === "warn" ? yellow : accent, text: shells.text });
3556
3785
  // LAST, so it is the first to give way on a narrow window: housekeeping, never urgent (#329).
3786
+ // GH #597: a nearly full disk — before the database item: nothing can be saved once it is full.
3787
+ const disk = lowDiskNotice(diskFree);
3788
+ if (disk) items.push({ key: "disk", clickable: true, paint: yellow, text: disk.text });
3789
+ // GH #594: the database, when it is big enough to matter (1 GB; yellow from 5 GB).
3790
+ const db = gudbNoticeSync(gudbSize);
3791
+ if (db) items.push({ key: "gudb", clickable: true, paint: db.urgent ? yellow : dim, text: db.text });
3557
3792
  const logs = clearLogsNoticeText(logsBytes);
3558
3793
  if (logs) items.push({ key: "logs", clickable: true, paint: dim, text: logs });
3559
3794
  return noticeRow(items, { width, gutter: GUTTER });
3560
3795
  }
3561
3796
 
3797
+ /**
3798
+ * GH #602: the gu token notice on its OWN row, directly above the separator and below the clickable
3799
+ * notices — the owner: the update link on one line, the trial on the next, nothing squeezed together.
3800
+ * Cut with "…" when the window is too narrow; null when there is nothing to say.
3801
+ */
3802
+ function zoneTokenRow(width) {
3803
+ if (!tokenNotice?.text || tokenQuestionOpen) return null;
3804
+ const paint = tokenNotice.urgent ? yellow : dim;
3805
+ return GUTTER + paint(clipVisible(tokenNotice.text, Math.max(10, width - GUTTER.length - 1)));
3806
+ }
3807
+
3562
3808
  /**
3563
3809
  * The whole frozen zone, top to bottom: a separator, a blank row, the INPUT LINE, then the
3564
3810
  * bar's rule, token and mode rows. The blank is what lifts the separator — and the control it
@@ -3617,6 +3863,7 @@ function frozenZone() {
3617
3863
  // control, the gu token notice, the agents count — is on its own NOTICE ROW above it; the head
3618
3864
  // is just the rule, with no blank to lift a control off the typed line.
3619
3865
  const notice = zoneNotice(width);
3866
+ const tokenRow = zoneTokenRow(width); // GH #602: below the clickable notices, a row of its own
3620
3867
  const zone = inputZoneRows({
3621
3868
  headControl: false,
3622
3869
  width,
@@ -3666,19 +3913,23 @@ function frozenZone() {
3666
3913
  ghost: nextHint && promptIdleForHint() ? dim(ghostText(nextHint)) : "",
3667
3914
  });
3668
3915
  const footer = footerBuilt();
3669
- const rows = status.concat(notice ? [notice.row] : [], zone.rows, askHintRows(width), footer.rows);
3916
+ const rows = status.concat(notice ? [notice.row] : [], tokenRow ? [tokenRow] : [], zone.rows, askHintRows(width), footer.rows);
3670
3917
  // The footer is the LAST rows of the zone, so the link's row counts from the end.
3671
3918
  supportLinkTarget = footer.link ? { fromEnd: footer.rows.length - footer.link.rowIndex, from: footer.link.from, to: footer.link.to } : null;
3672
3919
  // The separator is `status.length (+1 for the notice row)` rows down — everything that writes to
3673
3920
  // or hit-tests a row by index counts from here.
3674
- const sep = status.length + (notice ? 1 : 0);
3921
+ const sep = status.length + (notice ? 1 : 0) + (tokenRow ? 1 : 0);
3675
3922
  updateRowTarget = notice?.spans.update ?? null;
3676
3923
  agentsRowTarget = notice?.spans.agents ?? null;
3677
3924
  limitsRowTarget = notice?.spans.limits ?? null;
3678
3925
  logsRowTarget = notice?.spans.logs ?? null;
3926
+ gudbRowTarget = notice?.spans.gudb ?? null;
3927
+ diskRowTarget = notice?.spans.disk ?? null;
3679
3928
  shellsRowTarget = notice?.spans.shells ?? null;
3680
3929
  jumpSpan = notice?.spans.jump ?? null;
3681
- return { ...zone, rows, statusRows: sep, noticeRow: Boolean(notice) };
3930
+ // noticeRow: how many rows ABOVE the separator the clickable notice row is (0 = none) — 2 when the
3931
+ // token row sits between them (GH #602).
3932
+ return { ...zone, rows, statusRows: sep, noticeRow: notice ? (tokenRow ? 2 : 1) : 0 };
3682
3933
  }
3683
3934
  /**
3684
3935
  * Put the output position back at column 0 of its own row — without printing anything.
@@ -3744,9 +3995,9 @@ function paintBar() {
3744
3995
  // looking at rather than re-deriving them from rl.line at a width this may not be.
3745
3996
  inputRowTexts = zone.rows.slice((zone.statusRows ?? 0) + head);
3746
3997
  // THE NOTICE ROW is the one directly above the separator (#318) — never the separator itself.
3747
- const noticeAbs = zone.noticeRow ? sepAbs - 1 : 0;
3998
+ const noticeAbs = zone.noticeRow ? sepAbs - zone.noticeRow : 0;
3748
3999
  jumpRowTarget = scrolledBack() && jumpSpan ? { row: noticeAbs, ...jumpSpan } : null;
3749
- updateRowAbs = updateRowTarget || agentsRowTarget || limitsRowTarget || logsRowTarget || shellsRowTarget ? noticeAbs : 0;
4000
+ updateRowAbs = updateRowTarget || agentsRowTarget || limitsRowTarget || logsRowTarget || gudbRowTarget || diskRowTarget || shellsRowTarget ? noticeAbs : 0;
3750
4001
  // preserveCaret:false — the save slot holds the OUTPUT position (see regionUi), and the caret
3751
4002
  // is parked on the input line right after, so there is nothing to preserve here.
3752
4003
  ui(
@@ -3910,6 +4161,8 @@ let agentsRowTarget = null;
3910
4161
  let limitsRowTarget = null;
3911
4162
  // …and "clear logs · 175 MB" (#329), shown only once the logs are worth a row.
3912
4163
  let logsRowTarget = null;
4164
+ let gudbRowTarget = null; // GH #594
4165
+ let diskRowTarget = null; // GH #597
3913
4166
  // …and "1 shell running (click)" (#360) — a long command the agent left running in the background.
3914
4167
  let shellsRowTarget = null;
3915
4168
  // A terminal left with a scrolling region is a broken shell — a hard guarantee, like the
@@ -7793,6 +8046,28 @@ async function quickSwitch() {
7793
8046
  }
7794
8047
  }
7795
8048
 
8049
+ /**
8050
+ * GH #588: /model while a turn runs. The pickers work mid-turn (a command approval uses one), and
8051
+ * the turn keeps the coder it was sent with — its job payload names it — so the choice simply
8052
+ * waits for the next turn. Say which model finishes this one, so the bar's new name can't mislead.
8053
+ */
8054
+ async function chooseModelDuringTurn() {
8055
+ if (listPickerActive || approvalActive || zonePanel) return;
8056
+ const before = { url: activeCodingUrl(), model: activeCodingModelId() };
8057
+ console.log("");
8058
+ try {
8059
+ await chooseModel();
8060
+ } catch (e) {
8061
+ console.log(GUTTER + red(`could not change the model: ${e?.message ?? e}`));
8062
+ }
8063
+ const after = { url: activeCodingUrl(), model: activeCodingModelId() };
8064
+ const changed = after.url !== before.url || after.model !== before.model;
8065
+ if (changed && following) {
8066
+ console.log(GUTTER + accent(`✓ your next turn uses ${after.model}`) + dim(` — this one finishes on ${before.model}`) + "\n");
8067
+ }
8068
+ paintBar();
8069
+ }
8070
+
7796
8071
  async function chooseModel() {
7797
8072
  let probe;
7798
8073
  try {
@@ -9809,7 +10084,83 @@ async function runLimitsSeen() {
9809
10084
  let logsBytes = 0; // what the notice shows; only the logs are measured for it (a handful of stats)
9810
10085
  let clearLogsBusy = false;
9811
10086
 
10087
+ let gudbSize = 0; // GH #594: the local database's size, when this computer uses gudb (else 0)
10088
+ let diskFree = null; // GH #597: free bytes where ~/.gu lives; null = not measured
10089
+ async function refreshGudbSize() {
10090
+ try {
10091
+ const { readLocalDb } = await import("./client-expert-api.mjs");
10092
+ const was = gudbSize;
10093
+ const gs = await import("./gudb-size.mjs");
10094
+ gudbSize = readLocalDb() === "gudb" ? gs.gudbBytes() : 0;
10095
+ // GH #597: free disk where gu keeps its data — on every computer, a full disk stops everything.
10096
+ const wasDisk = lowDiskNotice(diskFree)?.text;
10097
+ diskFree = gs.freeDiskBytes();
10098
+ if ((gs.gudbNotice(was)?.text !== gs.gudbNotice(gudbSize)?.text || wasDisk !== lowDiskNotice(diskFree)?.text) && barPinned()) paintBar();
10099
+ } catch {
10100
+ /* a housekeeping notice is never worth an error */
10101
+ }
10102
+ }
10103
+
10104
+ /**
10105
+ * /backup-db (GH #598): a copy made by SQLite itself (VACUUM INTO) — a plain file copy of a running
10106
+ * database can be broken or miss what is still in its WAL file. ~/.gu/gudb/backups, newest 3 kept.
10107
+ */
10108
+ async function runBackupDb() {
10109
+ const { readLocalDb } = await import("./client-expert-api.mjs");
10110
+ if (readLocalDb() !== "gudb") {
10111
+ console.log(GUTTER + dim("This computer doesn't use gu's built-in database — nothing to back up here.") + "\n");
10112
+ return;
10113
+ }
10114
+ const gs = await import("./gudb-size.mjs");
10115
+ const r = await withPendingStatus("backing up the database", async () => gs.backupGudb());
10116
+ const tilde = (p) => (p.startsWith(homedir()) ? "~" + p.slice(homedir().length) : p);
10117
+ if (r.error) console.log(GUTTER + red(`couldn't back up: ${r.error}`) + "\n");
10118
+ else {
10119
+ console.log(GUTTER + accent(`✓ backed up — ${tilde(r.file)} (${gs.gudbHuman(r.bytes)})`) +
10120
+ (r.removed.length ? dim(` · ${r.removed.length} older backup${r.removed.length === 1 ? "" : "s"} removed, the last ${gs.KEEP_BACKUPS} kept`) : ""));
10121
+ console.log(GUTTER + dim("To restore: quit gu, then put that file in place of ~/.gu/gudb/gu.db (and delete gu.db-wal and gu.db-shm).") + "\n");
10122
+ }
10123
+ paintBar();
10124
+ }
10125
+
10126
+ /**
10127
+ * "Clean old data" (GH #594, the owner's suggestion): ONE click on the database notice, no
10128
+ * questions — saved model prompts/replies older than 30 days go (rows and usage numbers stay),
10129
+ * then the file is compacted so the disk space comes back. /clear-logs keeps the step-by-step
10130
+ * version, which can go down to 14 days.
10131
+ */
10132
+ let cleanOldDataBusy = false;
10133
+ async function runCleanOldData() {
10134
+ if (cleanOldDataBusy || listPickerActive || approvalActive) return;
10135
+ // Compacting locks the database: gu's API would wait on it in the middle of a turn.
10136
+ if (following) {
10137
+ console.log("\n" + GUTTER + dim("Clean old data waits for this turn to finish — click it again then.") + "\n");
10138
+ return;
10139
+ }
10140
+ cleanOldDataBusy = true;
10141
+ try {
10142
+ const gs = await import("./gudb-size.mjs");
10143
+ console.log("\n" + GUTTER + dim(`Cleaning saved model text older than ${gs.AUTO_KEEP_TEXT_DAYS} days and compacting — this can take a minute…`));
10144
+ const r = await withPendingStatus("cleaning old data", async () => gs.clearOldText({ days: gs.AUTO_KEEP_TEXT_DAYS }));
10145
+ if (r.error) {
10146
+ console.log(GUTTER + red(`couldn't clean: ${r.error}`) + "\n");
10147
+ } else {
10148
+ const size = `${gs.gudbHuman(r.before)} → ${gs.gudbHuman(r.after)}`;
10149
+ if (r.cleared) console.log(GUTTER + accent(`✓ old data cleaned — ${r.cleared} step${r.cleared === 1 ? "" : "s"}, ${size}`));
10150
+ else console.log(GUTTER + accent(`✓ compacted — ${size}`) + dim(` · nothing was older than ${gs.AUTO_KEEP_TEXT_DAYS} days`));
10151
+ if (!r.compacted) console.log(GUTTER + yellow("The file couldn't be compacted now (gu was busy or the disk is too full) — the space is reused for new data."));
10152
+ if (gs.gudbNotice(r.after)) console.log(GUTTER + dim(`Still big: it is mostly recent. /clear-logs can remove saved text older than ${gs.KEEP_TEXT_DAYS} days.`));
10153
+ console.log("");
10154
+ }
10155
+ } finally {
10156
+ cleanOldDataBusy = false;
10157
+ await refreshGudbSize();
10158
+ paintBar();
10159
+ }
10160
+ }
10161
+
9812
10162
  async function refreshLogsSize() {
10163
+ void refreshGudbSize();
9813
10164
  try {
9814
10165
  const { surveyLogs } = await import("./clear-logs.mjs");
9815
10166
  const was = clearLogsNoticeText(logsBytes);
@@ -9992,6 +10343,32 @@ async function runClearLogs() {
9992
10343
  }
9993
10344
  }
9994
10345
 
10346
+ // 4. THE DATABASE (GH #594) — the saved prompt/response text of older steps; the rows and the
10347
+ // usage numbers stay. Only on a gudb computer, and only when there is old text to remove.
10348
+ const gs = await import("./gudb-size.mjs");
10349
+ const { readLocalDb } = await import("./client-expert-api.mjs");
10350
+ const dbs = readLocalDb() === "gudb" ? gs.surveyGudb() : null;
10351
+ if (dbs?.oldText.rows) {
10352
+ question(`Also remove saved model prompts and replies older than ${dbs.days} days from gu's database — ${cl.humanSize(dbs.oldText.bytes)} in ${dbs.oldText.rows} step${dbs.oldText.rows === 1 ? "" : "s"}? (database: ${cl.humanSize(dbs.bytes)})`);
10353
+ // Can't be undone (like RAG and the API above), so No is the first row.
10354
+ const go = await pickFromList(["No — keep it", "Yes — remove that text" + dim(" · usage numbers, jobs and settings stay")], 0);
10355
+ if (go < 0) return cancelled();
10356
+ if (go === 1) {
10357
+ console.log(GUTTER + dim("Removing and compacting the database…"));
10358
+ const r = gs.clearOldText();
10359
+ if (r.error) console.log(GUTTER + red(`couldn't clean the database — ${r.error}`));
10360
+ else {
10361
+ freed.push({ what: "gudb", freed: r.freed });
10362
+ console.log(GUTTER + accent(`✓ text removed from ${r.cleared} step${r.cleared === 1 ? "" : "s"} — ${cl.humanSize(r.freed)} freed`) +
10363
+ (r.compacted ? "" : yellow(" (the file couldn't be compacted now — gu was busy or the disk is full; it shrinks on the next cleanup)")));
10364
+ }
10365
+ } else {
10366
+ console.log(GUTTER + dim("database text kept"));
10367
+ }
10368
+ } else if (dbs) {
10369
+ console.log("\n" + GUTTER + dim(`gu's database: ${cl.humanSize(dbs.bytes)} — no saved text older than ${dbs.days} days.`));
10370
+ }
10371
+
9995
10372
  const total = freed.reduce((n, f) => n + f.freed, 0);
9996
10373
  console.log("\n" + GUTTER + (freed.length ? bold(`${cl.humanSize(total)} freed in all.`) : dim("Nothing removed.")) + "\n");
9997
10374
  } catch (e) {
@@ -11322,8 +11699,8 @@ async function showShells() {
11322
11699
  },
11323
11700
  });
11324
11701
  }
11325
- async function refreshOtherAgents() {
11326
- if (!barPinned() || following) return;
11702
+ async function refreshOtherAgents({ force = false } = {}) {
11703
+ if (!force && (!barPinned() || following)) return;
11327
11704
  try {
11328
11705
  const r = await fetch(`${apiBase}/api/worker/jobs`, {
11329
11706
  headers: { "X-Worker-Key": workerKey },
@@ -11365,7 +11742,10 @@ async function showOtherAgents() {
11365
11742
  // `listResolve`, stranding the first promise forever with the keyboard still routed to a
11366
11743
  // picker nobody can finish. Also refused during a turn: acting on another agent means
11367
11744
  // starting a follow, and this terminal can only run one turn.
11368
- if (listPickerActive || approvalActive || following) return;
11745
+ if (listPickerActive || approvalActive) return;
11746
+ // GH #586: during this terminal's own turn the click used to return here and do nothing.
11747
+ // The pickers can't run then (switching is a turn of its own) — a panel can.
11748
+ if (following) return void showOtherAgentsPanel();
11369
11749
  const width = Math.max(20, process.stdout.columns || 80);
11370
11750
  const agents = otherAgents; // …the snapshot this list is about; the poller may replace it
11371
11751
  // THE PICKER IS THE LIST. It used to print the agents and stop there, so now that each one
@@ -11422,6 +11802,56 @@ async function showOtherAgents() {
11422
11802
  submitSyntheticLine(ATTACH_PREFIX + agent.id);
11423
11803
  }
11424
11804
 
11805
+ /**
11806
+ * GH #586: the other agents IN PLACE OF THE INPUT BOX, while this terminal's turn runs — the same
11807
+ * kind of panel as a shell's details (#384). ↑↓ choose, s twice stops one, Esc closes. Switching
11808
+ * to one is a turn, so it waits for this one to end (a click then opens the picker).
11809
+ */
11810
+ async function showOtherAgentsPanel() {
11811
+ if (zonePanel) return;
11812
+ await refreshOtherAgents({ force: true }); // the 20s poll skips during a turn: the count may be old
11813
+ let sel = 0;
11814
+ let note = "";
11815
+ let armed = ""; // the id "s" was pressed on once
11816
+ const items = () => agentPickerItems(otherAgents, { width: Math.max(20, process.stdout.columns || 80) });
11817
+ openZonePanel({
11818
+ refreshMs: 1000,
11819
+ rows: (width, room) => agentsPanelRows({
11820
+ items: items(), sel, width, rows: Math.min(room, items().length + 2), note, gutter: GUTTER,
11821
+ style: { title: (t) => bold(accent(t)), mark: accent, dim },
11822
+ }),
11823
+ onKey: (key) => {
11824
+ const list = items();
11825
+ if (!list.length) return;
11826
+ if (key?.name === "up" || key?.name === "down") {
11827
+ sel = Math.min(list.length - 1, Math.max(0, sel + (key.name === "up" ? -1 : 1)));
11828
+ armed = "";
11829
+ note = "";
11830
+ } else if (key?.name === "s" && !key.ctrl && !key.meta) {
11831
+ const it = list[Math.min(sel, list.length - 1)];
11832
+ // Stopping can't be undone: the first s asks, the second does it.
11833
+ if (armed !== it.id) {
11834
+ armed = it.id;
11835
+ note = "press s again to stop it — its unsaved work is lost · any other key: no";
11836
+ } else {
11837
+ armed = "";
11838
+ note = "stopping…";
11839
+ const title = String((otherAgents.find((a) => a.id === it.id)?.title) ?? "that agent");
11840
+ void stopOtherAgent(it.id, title.length > 60 ? title.slice(0, 60) + "…" : title).then(() => {
11841
+ note = "";
11842
+ sel = Math.max(0, Math.min(sel, items().length - 1));
11843
+ paintBar();
11844
+ });
11845
+ }
11846
+ } else {
11847
+ armed = "";
11848
+ note = "";
11849
+ }
11850
+ paintBar();
11851
+ },
11852
+ });
11853
+ }
11854
+
11425
11855
  /**
11426
11856
  * Stop one of the account's other agents — the same POST Ctrl+C makes for this terminal's turn.
11427
11857
  *
@@ -15179,7 +15609,7 @@ async function main() {
15179
15609
  }
15180
15610
  try {
15181
15611
  const { loadState, saveState, askMode } = await import("./client-expert-run.mjs");
15182
- const { clientExpertAvailable, expertPlanPending, shouldAskMode, parseLicenseFlag, resolveFirstRunMode, promptForLicenseToken } =
15612
+ const { clientExpertAvailable, expertPlanPending, shouldAskMode, parseLicenseFlag, resolveFirstRunMode, promptForLicenseToken, parseCloudFlag, checkCloudLink } =
15183
15613
  await import("./client-expert-setup.mjs");
15184
15614
  const st = await loadState();
15185
15615
  const { probeMachine } = await import("./client-expert-run.mjs");
@@ -15200,6 +15630,7 @@ async function main() {
15200
15630
  let plan = resolveFirstRunMode({
15201
15631
  licenseToken: licenseToken1,
15202
15632
  expertAvailable: gate.available,
15633
+ cloudCode: await cloudLinkForFirstRun(parseCloudFlag(argv), checkCloudLink), // GH #603
15203
15634
  });
15204
15635
  if (plan.ask) {
15205
15636
  // Same as the first run: warn and re-ask on a bad token instead of silently picking
@@ -15262,6 +15693,7 @@ async function main() {
15262
15693
  } catch {
15263
15694
  /* never block the REPL on the mode question — the banner still shows what is configured */
15264
15695
  }
15696
+ await claimCloudLinkIfAsked(); // GH #603: `gu --cloud <code>` — this account takes the link
15265
15697
 
15266
15698
  try {
15267
15699
  const ctl = await import("./daemon-control.mjs");
@@ -16062,6 +16494,7 @@ async function main() {
16062
16494
  archivedUpTo = await seedArchive(cwd, history).catch(() => history.length);
16063
16495
  // A new gu session (task #270): the agent runs onStart hooks on the first turn it sees this id.
16064
16496
  await startHookSession(cwd);
16497
+ void refreshMemoryTask(); // GH #595: which task this session's work goes to, on the bar
16065
16498
  if (history.length > 0) {
16066
16499
  const turns = history.filter((m) => m.role === "user").length;
16067
16500
  console.log(
@@ -16393,19 +16826,7 @@ async function main() {
16393
16826
  continue;
16394
16827
  }
16395
16828
  if (line === "/suggestions" || line.startsWith("/suggestions ")) {
16396
- // GH #536: the suggested next message after a turn — on by default, remembered for every folder.
16397
- suggestionsOn = suggestionsToggle(line.slice("/suggestions".length), suggestionsOn);
16398
- try {
16399
- mkdirSync(dirname(SUGGESTIONS_FILE), { recursive: true });
16400
- writeFileSync(SUGGESTIONS_FILE, suggestionsOn ? "on\n" : "off\n");
16401
- } catch {}
16402
- if (!suggestionsOn) clearNextHint();
16403
- console.log(
16404
- GUTTER + (suggestionsOn ? accent("suggestions: ON") : dim("suggestions: OFF")) +
16405
- dim(suggestionsOn
16406
- ? " — after some answers a next message appears in the input; Tab takes it.\n"
16407
- : " — no suggested next message after a turn. /suggestions on brings it back.\n")
16408
- );
16829
+ setSuggestions(line.slice("/suggestions".length));
16409
16830
  continue;
16410
16831
  }
16411
16832
  if (line === "/hover") {
@@ -16519,6 +16940,7 @@ async function main() {
16519
16940
  }
16520
16941
  if (line === "/switch-skill" || line.startsWith("/switch-skill ")) {
16521
16942
  await runSwitchSkillCommand(line);
16943
+ void refreshMemoryTask(); // GH #595: the bar says whose skills, and whether the memory is in them
16522
16944
  continue;
16523
16945
  }
16524
16946
  if (line === "/skill-pack" || line.startsWith("/skill-pack ")) {
@@ -16641,6 +17063,7 @@ async function main() {
16641
17063
  const where = await startNewConversation(cwd, history);
16642
17064
  history.length = 0;
16643
17065
  await startHookSession(cwd); // a fresh session: onStart hooks run again (#270)
17066
+ void refreshMemoryTask(); // GH #595: a new session has no task of its own yet
16644
17067
  console.log(
16645
17068
  GUTTER + dim("New conversation started — this folder's settings are unchanged.") + "\n" +
16646
17069
  GUTTER + dim(kept
@@ -16662,30 +17085,20 @@ async function main() {
16662
17085
  await runClearLogs();
16663
17086
  continue;
16664
17087
  }
17088
+ if (line === "/task" || line === "/tasks") {
17089
+ await runTaskCommand();
17090
+ continue;
17091
+ }
17092
+ if (line === "/backup-db") {
17093
+ await runBackupDb();
17094
+ continue;
17095
+ }
16665
17096
  if (line === "/support") {
16666
17097
  await runSupport();
16667
17098
  continue;
16668
17099
  }
16669
17100
  if (line === "/budget") {
16670
- // #205: the short terminal version of web-v2's /providers budgets. The server judges Pro,
16671
- // the account email and "has items" (api/src/providers/terminalBudget.ts).
16672
- try {
16673
- const bv = await import("./budget-view.mjs");
16674
- const ct = await import("./cli-token.mjs");
16675
- const { DEFAULT_API_BASE } = await import("./device-login.mjs");
16676
- const state = await ct.readState(join(homedir(), ".gu"));
16677
- const result = await bv.fetchProvidersBudget({
16678
- apiBase,
16679
- workerKey,
16680
- hostedBase: String(process.env.GU_TOKEN_API_BASE ?? "").trim() || DEFAULT_API_BASE,
16681
- token: state.token,
16682
- });
16683
- const out = bv.budgetLines(result, { site: ct.siteUrl() });
16684
- for (const l of out.lines) console.log(GUTTER + (out.tone === "ok" ? l : dim(l)));
16685
- console.log("");
16686
- } catch (e) {
16687
- console.log(GUTTER + dim(`Could not show your budgets: ${e instanceof Error ? e.message : e}\n`));
16688
- }
17101
+ await showBudget();
16689
17102
  continue;
16690
17103
  }
16691
17104
  if (line === "/tokens") {
@@ -16988,6 +17401,7 @@ async function main() {
16988
17401
  if (fellBack) printFallbackLine(fellBack);
16989
17402
  // GH #536: maybe a suggested next message — not when a queued question runs next anyway.
16990
17403
  if (turnQueue.size === 0 && _lineQueue.length === 0) offerNextHint(taskLine, answer);
17404
+ void refreshMemoryTask(); // GH #595: the turn may have created or switched the task
16991
17405
  } else {
16992
17406
  // A turn that ended WITHOUT an answer (Ctrl+C cancel, or an abort/failure) must not
16993
17407
  // silently launch another turn. Any keystrokes the user typed DURING the dead turn