@tiens.nguyen/gu-cli 1.0.938 → 1.0.940

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.
Files changed (65) hide show
  1. package/README.md +17 -7
  2. package/agent-deps-preflight.mjs +1 -1
  3. package/autocompact.mjs +2 -2
  4. package/browser-bridge.mjs +2 -2
  5. package/browser-chrome.mjs +2 -2
  6. package/browser-command.mjs +4 -4
  7. package/browser-extension/README.md +6 -6
  8. package/clear-logs.mjs +3 -3
  9. package/clear-state.mjs +3 -3
  10. package/cli-token.mjs +8 -8
  11. package/client-expert-api.mjs +9 -9
  12. package/client-expert-run.mjs +7 -7
  13. package/client-expert-setup.mjs +4 -4
  14. package/command-allow.mjs +1 -1
  15. package/conversation-archive.mjs +2 -2
  16. package/credential-recovery.mjs +1 -1
  17. package/daemon-control.mjs +4 -4
  18. package/device-login.mjs +3 -3
  19. package/free-model.mjs +35 -3
  20. package/full-log-command.mjs +1 -1
  21. package/gonext_agent_chat.py +72 -72
  22. package/gu-cli.mjs +29 -28
  23. package/gu-home-move.mjs +193 -0
  24. package/gu-repl.mjs +72 -54
  25. package/gu_browser.py +3 -3
  26. package/gu_free_budget.py +11 -9
  27. package/gu_gif.py +1 -1
  28. package/gu_hooks.py +1 -1
  29. package/gu_mcp.py +22 -2
  30. package/gu_turn_notes.py +2 -2
  31. package/hooks-config.mjs +4 -4
  32. package/image-paste.mjs +8 -8
  33. package/install-path.mjs +1 -1
  34. package/log-level.mjs +1 -1
  35. package/log-policy.mjs +1 -1
  36. package/lsp-host.mjs +2 -2
  37. package/lsp-registry.mjs +9 -9
  38. package/mcp-command.mjs +1 -1
  39. package/mcp-config.mjs +5 -5
  40. package/model-doctor.mjs +10 -10
  41. package/mongo-mac.mjs +2 -2
  42. package/mongo-windows.mjs +3 -3
  43. package/package.json +2 -1
  44. package/platform-tools.mjs +3 -3
  45. package/poll-errors.mjs +2 -2
  46. package/prompt_scaffold_check.py +1 -1
  47. package/proxy-store.mjs +1 -1
  48. package/python-unix.mjs +6 -6
  49. package/python-windows.mjs +1 -1
  50. package/rag-selftest.mjs +2 -2
  51. package/resume-memory.mjs +1 -1
  52. package/scripts/image-paste-check.mjs +1 -1
  53. package/setup-fixes.mjs +4 -4
  54. package/shell-details.mjs +2 -2
  55. package/skill-install.mjs +9 -9
  56. package/skill-package.mjs +10 -10
  57. package/skill-source.mjs +4 -4
  58. package/skills-copy.mjs +15 -15
  59. package/skills.mjs +4 -4
  60. package/support-bundle.mjs +6 -6
  61. package/support-report.mjs +5 -5
  62. package/terminal-layout.mjs +1 -1
  63. package/turn-notes.mjs +2 -2
  64. package/version-check.mjs +1 -1
  65. package/workspace-revert.mjs +2 -2
package/gu-repl.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
  * $ gu
8
8
  *
9
9
  * It offers to register the CURRENT folder as an agent workspace (with a trust prompt
10
- * that maps to --allow-run), authenticates with the worker key from ~/.gonext/worker.env
10
+ * that maps to --allow-run), authenticates with the worker key from ~/.gu/worker.env
11
11
  * (the same file `gu-cli set` / the Wizard write), and loops on a `>> `
12
12
  * prompt. Each question is ENQUEUED as a normal agent_chat job (models/budgets/RAG
13
13
  * resolved from your user settings by POST /api/worker/agent-ask) and executed by the
@@ -15,7 +15,7 @@
15
15
  * logs, exactly like a web question. The REPL polls the job and streams the persisted
16
16
  * chunks live into the terminal.
17
17
  *
18
- * Conversation history is saved to ~/.gonext/sessions/<hash-of-folder-path>.json after
18
+ * Conversation history is saved to ~/.gu/sessions/<hash-of-folder-path>.json after
19
19
  * every turn and reloaded on the next `gu` in the SAME folder — so closing the
20
20
  * terminal and coming back later still has context (e.g. "continue" after an
21
21
  * interrupted investigation actually resumes it). /new clears it.
@@ -24,8 +24,9 @@
24
24
  * Commands: /exit /model /new /help Ctrl-C stops following the current run.
25
25
  */
26
26
  import { RELAUNCHED } from "./gu-relaunch.mjs"; // FIRST: may replace this process (#358)
27
+ import { moveProjectToGu } from "./gu-home-move.mjs"; // GH #582: moves the old home folder to ~/.gu once, before anything uses it
27
28
  import { installInternalLabel } from "./cli-token.mjs";
28
- installInternalLabel(); // our own machines only (GU_INTERNAL_LABEL / ~/.gonext/internal-label): label gucli.com requests
29
+ installInternalLabel(); // our own machines only (GU_INTERNAL_LABEL / ~/.gu/internal-label): label gucli.com requests
29
30
  import { readFile, mkdir, writeFile, unlink, rename } from "node:fs/promises";
30
31
  import { readStepTokens, readTurnCache } from "./step-tokens.mjs";
31
32
  import { snapshotInput, restoreInput, replaceStoppedQuestion, restoredQuestionLetGo, stopNoteLines } from "./turn-stop.mjs";
@@ -233,6 +234,8 @@ import {
233
234
  zoneResizePlan,
234
235
  blockClosedPad,
235
236
  } from "./terminal-viewport.mjs";
237
+ // GH #582: a project that still has gu's old folder gets it renamed to ./.gu, once.
238
+ if (process.env.GU_NO_HOME_MOVE !== "1") for (const l of moveProjectToGu()) process.stderr.write(` ${l}\n`);
236
239
 
237
240
  const DIR = dirname(fileURLToPath(import.meta.url));
238
241
 
@@ -258,9 +261,9 @@ setInterval(() => {
258
261
  /* try again next time */
259
262
  }
260
263
  }, 20_000).unref();
261
- const ENV_FILE = join(homedir(), ".gonext", "worker.env");
262
- const WS_FILE = join(homedir(), ".gonext", "workspaces.json");
263
- const SESSIONS_DIR = join(homedir(), ".gonext", "sessions");
264
+ const ENV_FILE = join(homedir(), ".gu", "worker.env");
265
+ const WS_FILE = join(homedir(), ".gu", "workspaces.json");
266
+ const SESSIONS_DIR = join(homedir(), ".gu", "sessions");
264
267
 
265
268
  // Through paint() so NO_COLOR / GU_ACCENT=off / TERM=dumb turn ALL of them off, not only the
266
269
  // accent (task #29 bug B1 — red '-' rows stayed red under NO_COLOR).
@@ -335,7 +338,20 @@ const wrapBlock = (text, indent, width) => {
335
338
  // indented to the shared text column (GUTTER) so it lines up with the bullets' text and the
336
339
  // rest of the output, with inline **bold** rendered per row (after wrapping, so the width math
337
340
  // is on visible text).
338
- const renderAnswer = (answer) =>
341
+ // GH #579: a pause answer (gu_free_budget.py) opens with ONE "Paused — …" line: that line is the warning colour.
342
+ const PAUSE_LINE_RE = /^Paused — /;
343
+ const renderAnswer = (answer) => {
344
+ const s = String(answer ?? "");
345
+ if (PAUSE_LINE_RE.test(s)) {
346
+ const nl = s.indexOf("\n");
347
+ const head = nl < 0 ? s : s.slice(0, nl);
348
+ const rest = nl < 0 ? "" : s.slice(nl);
349
+ const headRows = wrapBlock(head, GUTTER, process.stdout.columns || 80).map((l) => (l.length ? GUTTER + yellow(l) : l));
350
+ return headRows.join("\n") + (rest ? "\n" + renderAnswerRows(rest.replace(/^\n/, "")) : "");
351
+ }
352
+ return renderAnswerRows(s);
353
+ };
354
+ const renderAnswerRows = (answer) =>
339
355
  wrapBlock(answer, GUTTER, process.stdout.columns || 80)
340
356
  .map((l) => (l.length ? GUTTER + renderMdBold(l) : l))
341
357
  .join("\n");
@@ -684,7 +700,7 @@ if (cliVerdict.kind === "run") {
684
700
  " gu doctor|login|set # models / account (same as `gu-cli …`)\n" +
685
701
  " gu rag # is RAG working? tests the embedder end-to-end\n\n" +
686
702
  " -v, --verbose show RAG index-file activity in the bottom bar (each shard written)\n" +
687
- " --log log this run in detail (~/.gonext/worker.log). Without it only starts,\n" +
703
+ " --log log this run in detail (~/.gu/worker.log). Without it only starts,\n" +
688
704
  " stops and errors are logged. Ends when this gu closes.\n" +
689
705
  " --color colour the live thought, the thinking spinner and its playful word.\n" +
690
706
  " Without it they are plain white.\n" +
@@ -694,13 +710,13 @@ if (cliVerdict.kind === "run") {
694
710
  " client / MLX host / private). Without it, a first install is\n" +
695
711
  " private by default — the whole stack on this machine.\n" +
696
712
  " -h, --help this help\n\n" +
697
- "Auth comes from ~/.gonext/worker.env; models/budgets/RAG come from your web Settings.\n" +
713
+ "Auth comes from ~/.gu/worker.env; models/budgets/RAG come from your web Settings.\n" +
698
714
  "Inside the REPL: /exit · /model · /new · /help — Ctrl-C stops following a turn.\n" +
699
715
  "Questions are enqueued like web questions and executed by the RUNNING\n" +
700
716
  "gu-cli daemon — its terminal shows the full [gu-agent] logs.\n" +
701
- "Conversation history is saved per-folder in ~/.gonext/sessions and resumed next time\n" +
717
+ "Conversation history is saved per-folder in ~/.gu/sessions and resumed next time\n" +
702
718
  "you run `gu` in the same folder; /new starts a new conversation and keeps the old one\n" +
703
- "in ~/.gonext/sessions/archive."
719
+ "in ~/.gu/sessions/archive."
704
720
  );
705
721
  process.exit(0);
706
722
  }
@@ -710,7 +726,7 @@ if (cliVerdict.kind === "run") {
710
726
  // the job stream. It now drives a real, streamable signal.
711
727
  const REPL_VERBOSE = argv.includes("-v") || argv.includes("--verbose");
712
728
  // --log (task #352): THIS RUN logs in detail. By default the worker writes only starts, stops and
713
- // errors; a run started with --log takes a lease (its pid, in ~/.gonext/log-detail.json) that the
729
+ // errors; a run started with --log takes a lease (its pid, in ~/.gu/log-detail.json) that the
714
730
  // worker reads, and gives it back on exit. Per run by the owner's rule — nothing is saved, and a
715
731
  // run that is killed leaves a lease for a dead process, which is no lease.
716
732
  const REPL_LOG = argv.includes("--log");
@@ -736,7 +752,7 @@ if (REPL_LOG) {
736
752
  const ll = await import("./log-level.mjs");
737
753
  await ll.takeLease().catch(() => {});
738
754
  process.on("exit", () => ll.releaseLeaseSync());
739
- console.log(dim(" --log: detailed logging is on for this run (~/.gonext/worker.log); back to minimal when gu closes."));
755
+ console.log(dim(" --log: detailed logging is on for this run (~/.gu/worker.log); back to minimal when gu closes."));
740
756
  }
741
757
 
742
758
  // WHAT THE INSTALL DID, FIRST (GH #557 follow-up): npm hides postinstall output, so gu says what
@@ -780,14 +796,14 @@ if (REPL_VERBOSE) {
780
796
  process.env.GONEXT_REPL_VERBOSE = "1";
781
797
  }
782
798
 
783
- // ---------- auth: worker key + API base from ~/.gonext/worker.env ----------
799
+ // ---------- auth: worker key + API base from ~/.gu/worker.env ----------
784
800
  dotenv.config({ path: ENV_FILE });
785
801
  dotenv.config();
786
802
  let workerKey = String(process.env.GONEXT_WORKER_KEY ?? "").trim();
787
803
  let apiBase = String(process.env.GONEXT_API_BASE ?? "").trim().replace(/\/+$/, "");
788
804
 
789
805
  /**
790
- * Re-read ~/.gonext/worker.env into this process.
806
+ * Re-read ~/.gu/worker.env into this process.
791
807
  *
792
808
  * Client Expert setup WRITES that file mid-run, so without this the very first session after
793
809
  * setup still holds the values it started with — the banner and every request would describe
@@ -1134,11 +1150,11 @@ const COMMANDS = [
1134
1150
  { name: "/new", desc: "start a new conversation in this folder — the old one is kept (archived); the folder's settings stay" },
1135
1151
  { name: "/hooks", usage: "/hooks [list|approve|unapprove]", desc: "hooks: commands gu runs on onStart, onAsk, onToolDone, onTurnEnd — list them, approve this project's" },
1136
1152
  { 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" },
1137
- { 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 (.gonext)" },
1153
+ { 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)" },
1138
1154
  { name: "/resume", desc: "carry on the last unfinished task in this folder — Claude Code's or gu's — from where it stopped (memory skill)" },
1139
1155
  { 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" },
1140
1156
  { 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)" },
1141
- { name: "/skills-copy-to-claude", usage: "/skills-copy-to-claude [--dry-run] [name…]", desc: "copy gu's skills (.gonext) into Claude Code's folders (.claude), renamed to Claude's names, with their MCP servers" },
1157
+ { name: "/skills-copy-to-claude", usage: "/skills-copy-to-claude [--dry-run] [name…]", desc: "copy gu's skills (.gu) into Claude Code's folders (.claude), renamed to Claude's names, with their MCP servers" },
1142
1158
  { name: "/help", desc: "list these commands" },
1143
1159
  { name: "/exit", aliases: ["/quit"], desc: "quit" },
1144
1160
  ];
@@ -1146,8 +1162,8 @@ const COMMANDS = [
1146
1162
  // terminal-layout.mjs — their handlers are below, above the unknown-command guard. Not
1147
1163
  // imported here: nothing in the REPL reads the list, the tests do (task #153).
1148
1164
  const COMMAND_NAMES = COMMANDS.flatMap((c) => [c.name, ...(c.aliases ?? [])]);
1149
- // SKILLS ARE COMMANDS TOO (task #269): each ~/.gonext/skills/<name>/SKILL.md (and this folder's
1150
- // .gonext/skills) is /<name>, in Tab-completion and /help like any other. Scanned from disk — kept
1165
+ // SKILLS ARE COMMANDS TOO (task #269): each ~/.gu/skills/<name>/SKILL.md (and this folder's
1166
+ // .gu/skills) is /<name>, in Tab-completion and /help like any other. Scanned from disk — kept
1151
1167
  // for 2s only, because the overlay asks on every keystroke — so a skill added, edited or DELETED
1152
1168
  // while gu runs shows up (or quietly disappears) without a restart. A built-in name always wins.
1153
1169
  let _skillScan = { at: 0, skills: [] };
@@ -1902,7 +1918,7 @@ if (TITLE_ON) {
1902
1918
  }
1903
1919
 
1904
1920
  // ---------- language servers (GH #539/#540) --------------------------------------------------
1905
- // The choices live in ~/.gonext/lsp-state.json (the offer and /lsp write it); the worker's host
1921
+ // The choices live in ~/.gu/lsp-state.json (the offer and /lsp write it); the worker's host
1906
1922
  // (lsp-host.mjs) reads it, runs the servers, and says what is running on /status.
1907
1923
  const loadLspState = () => {
1908
1924
  try {
@@ -2058,7 +2074,7 @@ async function autocompactCommand(arg) {
2058
2074
  // ---------- the next message, suggested (GH #536) -------------------------------------------
2059
2075
  // After SOME turns the empty input shows a dim suggestion; Tab puts it in the input. See
2060
2076
  // next-suggestion.mjs for when (two gates: cheap rules, then the coder answering NONE or a reply).
2061
- const SUGGESTIONS_FILE = join(homedir(), ".gonext", "prompt-suggestions");
2077
+ const SUGGESTIONS_FILE = join(homedir(), ".gu", "prompt-suggestions");
2062
2078
  let suggestionsOn = (() => {
2063
2079
  try {
2064
2080
  return suggestionsOnFromFile(readFileSync(SUGGESTIONS_FILE, "utf8"));
@@ -2322,7 +2338,7 @@ function showImageNotice(text) {
2322
2338
  }
2323
2339
  /**
2324
2340
  * Images go to the coding model when it takes them: Claude, Kimi K3 (image-capable-coders.json), and
2325
- * since GH #528 every model the cloud list marks `images: true` — read from ~/.gonext/image-models.json
2341
+ * since GH #528 every model the cloud list marks `images: true` — read from ~/.gu/image-models.json
2326
2342
  * at start, refreshed with the cloud token table (refreshLimitsUpdate).
2327
2343
  */
2328
2344
  loadCloudImageCoders();
@@ -2948,7 +2964,7 @@ async function refreshAvailableUpdates() {
2948
2964
  const { readdir } = await import("node:fs/promises");
2949
2965
  const { existsSync } = await import("node:fs");
2950
2966
  const { pickUsableVersion } = await import("./version-check.mjs");
2951
- const base = join(homedir(), ".gonext", "api");
2967
+ const base = join(homedir(), ".gu", "api");
2952
2968
  const dirs = await readdir(base).catch(() => []);
2953
2969
  apiRunning = pickUsableVersion(dirs, (v) =>
2954
2970
  existsSync(join(base, v, "node_modules", "mongodb", "package.json"))
@@ -3015,7 +3031,7 @@ async function refreshCliToken() {
3015
3031
  tokenNotice = null; // no key (none embedded, GU_CLI_TOKEN_PUBLIC_KEY empty): nothing to check against
3016
3032
  return;
3017
3033
  }
3018
- const dir = join(homedir(), ".gonext");
3034
+ const dir = join(homedir(), ".gu");
3019
3035
  const mode = isClientExpert() ? "expert" : "client";
3020
3036
  const site = ct.siteUrl();
3021
3037
  let state = await ct.readState(dir);
@@ -3081,7 +3097,7 @@ const TOKEN_TICK_MS = 60 * 60 * 1000;
3081
3097
 
3082
3098
  // The last in-app CLI update attempt (task #21): lets the next start say WHY an update did not
3083
3099
  // take effect instead of offering the very same update again, forever.
3084
- const UPDATE_ATTEMPT_FILE = join(homedir(), ".gonext", "last-cli-update.json");
3100
+ const UPDATE_ATTEMPT_FILE = join(homedir(), ".gu", "last-cli-update.json");
3085
3101
  function readUpdateAttempt() {
3086
3102
  try { return JSON.parse(readFileSync(UPDATE_ATTEMPT_FILE, "utf8")); } catch { return null; }
3087
3103
  }
@@ -8486,8 +8502,8 @@ function sayWrapped(text, paint = (s) => s, hang = " ") {
8486
8502
  }
8487
8503
  /**
8488
8504
  * /switch-skill — whose skills, MCP servers and hooks THIS FOLDER uses (task #325): Claude Code's,
8489
- * read where Claude keeps them (~/.claude, ./.claude, ~/.claude.json), or gu's own (~/.gonext,
8490
- * ./.gonext). One choice for all three — a skill names its MCP server's tools and the hooks feed
8505
+ * read where Claude keeps them (~/.claude, ./.claude, ~/.claude.json), or gu's own (~/.gu,
8506
+ * ./.gu). One choice for all three — a skill names its MCP server's tools and the hooks feed
8491
8507
  * the same database, so they only make sense together. Stored in the folder's session file, which
8492
8508
  * the worker reads for every turn (skill-source.mjs): it holds from the next question, no restart.
8493
8509
  */
@@ -8495,7 +8511,7 @@ async function runSwitchSkillCommand(line) {
8495
8511
  const cwd = resolve(process.cwd());
8496
8512
  const current = readSkillSource(cwd);
8497
8513
  const arg = (line.trim().split(/\s+/)[1] ?? "").toLowerCase();
8498
- const where = (src) => (src === "claude" ? "~/.claude, ./.claude, ~/.claude.json" : "~/.gonext, ./.gonext");
8514
+ const where = (src) => (src === "claude" ? "~/.claude, ./.claude, ~/.claude.json" : "~/.gu, ./.gu");
8499
8515
  let pick = "";
8500
8516
  console.log("");
8501
8517
  if (arg) {
@@ -8701,7 +8717,7 @@ async function runSkillInstallCommand(line) {
8701
8717
 
8702
8718
  /**
8703
8719
  * /skills-copy-to-claude [--dry-run] [name…] — gu's skills into Claude Code's folders (#241):
8704
- * ~/.gonext/skills → ~/.claude/skills and ./.gonext/skills → ./.claude/skills, "gu-" names become
8720
+ * ~/.gu/skills → ~/.claude/skills and ./.gu/skills → ./.claude/skills, "gu-" names become
8705
8721
  * "claude-", and a skill's MCP server goes into ~/.claude.json (skills-copy.mjs). Shows the plan,
8706
8722
  * then asks; a Claude skill that differs is kept unless the user picks "replace" (backed up).
8707
8723
  */
@@ -8725,7 +8741,7 @@ async function runSkillsCopyCommand(line) {
8725
8741
  for (const w of plan.warnings) say(yellow(w));
8726
8742
  if (plan.missing.length) say(yellow(`gu has no skill named ${plan.missing.join(", ")}`));
8727
8743
  if (!plan.items.length) {
8728
- say(dim("gu has no skills to copy — ~/.gonext/skills and ./.gonext/skills have none.\n"));
8744
+ say(dim("gu has no skills to copy — ~/.gu/skills and ./.gu/skills have none.\n"));
8729
8745
  return;
8730
8746
  }
8731
8747
  const word = { new: accent("new"), same: dim("already there"), differs: yellow("Claude's differs") };
@@ -8738,7 +8754,7 @@ async function runSkillsCopyCommand(line) {
8738
8754
  say(dim(` MCP server ${s.name} → ~/.claude.json${s.scope === "local" ? " (this folder)" : ""} `) + word[s.status]);
8739
8755
  }
8740
8756
  if (it.guLines.length) {
8741
- say(yellow(` SKILL.md line${it.guLines.length === 1 ? "" : "s"} ${it.guLines.join(", ")} still name${it.guLines.length === 1 ? "s" : ""} ~/.gonext — check the copy`));
8757
+ say(yellow(` SKILL.md line${it.guLines.length === 1 ? "" : "s"} ${it.guLines.join(", ")} still name${it.guLines.length === 1 ? "s" : ""} ~/.gu — check the copy`));
8742
8758
  }
8743
8759
  }
8744
8760
  const todo = plan.items.filter((i) => i.status !== "same" || i.servers.some((s) => s.status !== "same"));
@@ -9117,7 +9133,7 @@ async function applyTransferDoc(value, opts = {}) {
9117
9133
  ...opts,
9118
9134
  api: replPresetApi(),
9119
9135
  io: replPresetIo,
9120
- backupDir: join(homedir(), ".gonext", "preset-backups"),
9136
+ backupDir: join(homedir(), ".gu", "preset-backups"),
9121
9137
  host: hostname(),
9122
9138
  });
9123
9139
  if (result?.applied) await refreshAfterPresetApply(value, opts.codingDefault, result);
@@ -9203,7 +9219,7 @@ async function bannerAccount(settingsEmail = "") {
9203
9219
  try {
9204
9220
  const ct = await import("./cli-token.mjs");
9205
9221
  const pk = ct.publicKey();
9206
- const state = pk ? await ct.readState(join(homedir(), ".gonext")) : { token: "" };
9222
+ const state = pk ? await ct.readState(join(homedir(), ".gu")) : { token: "" };
9207
9223
  const check = state.token ? ct.verifyCliToken(state.token, pk) : { ok: false };
9208
9224
  return ct.accountLine({ payload: check.ok ? check.payload : null, settingsEmail });
9209
9225
  } catch {
@@ -9346,7 +9362,7 @@ async function noteTurnCost(inputTokens, breakdown, coder = null) {
9346
9362
  // ---------------------------------------------------------------------------------------------
9347
9363
  let freeModel = null; // the saved state (free-model.mjs), or null = no free model on this computer
9348
9364
  let freeModelNoticed = ""; // the level already shown this month, so a notice is said once
9349
- const freeModelDir = () => join(homedir(), ".gonext");
9365
+ const freeModelDir = () => join(homedir(), ".gu");
9350
9366
 
9351
9367
  async function freeModelHostedBase() {
9352
9368
  const { DEFAULT_API_BASE } = await import("./device-login.mjs");
@@ -9404,7 +9420,9 @@ async function setUpFreeModel({ token, announce = false } = {}) {
9404
9420
  : `✓ ${agentM} is now your agent model and ${got.preset.model} your coding model.`) +
9405
9421
  dim(" Free use renews each month; /model switches back to your own."));
9406
9422
  // GH #511: say plainly that setup is over and what to do now — the one line a new person needs.
9407
- console.log(GUTTER + bold("Ready — type your first question below and press Enter."));
9423
+ // GH #580: unless this month's allowance is already spent — then say that, and when it comes back.
9424
+ const spent = fm.spentAtSetup(freeModel, got.preset.baseUrl, new Date(), { redeemed: announce });
9425
+ console.log(GUTTER + (spent ? yellow(spent) : bold("Ready — type your first question below and press Enter.")));
9408
9426
  }
9409
9427
  return true;
9410
9428
  } catch (e) {
@@ -9421,7 +9439,7 @@ async function freeModelAtStart() {
9421
9439
  // Ask even with no saved state (GH #440/#442): a code redeemed while the server had no free model, or on
9422
9440
  // another computer, gets its model here without a second /voucher. Quiet unless there is one to set up.
9423
9441
  const ct = await import("./cli-token.mjs");
9424
- const st = await ct.readState(join(homedir(), ".gonext"));
9442
+ const st = await ct.readState(join(homedir(), ".gu"));
9425
9443
  if (st?.token) await setUpFreeModel({ token: st.token });
9426
9444
  } catch {
9427
9445
  /* the free model is never worth a failed start */
@@ -9430,7 +9448,7 @@ async function freeModelAtStart() {
9430
9448
 
9431
9449
  /** After a turn on the free model: count it, say a notice once per level, tell the service. Never throws. */
9432
9450
  // GH #507: how the agent's pause answer starts (gu_free_budget.py PAUSE_HEAD).
9433
- const ALLOWANCE_PAUSE_PREFIX = "Paused: this month's free-model allowance is used up";
9451
+ const ALLOWANCE_PAUSE_PREFIX = "Paused — this month's free-model allowance is used up";
9434
9452
 
9435
9453
  async function noteFreeModelTurn(inputTokens, breakdown, outputTokens, coder, aux = null, paused = false) {
9436
9454
  try {
@@ -9453,7 +9471,7 @@ async function noteFreeModelTurn(inputTokens, breakdown, outputTokens, coder, au
9453
9471
  console.log(GUTTER + (n.level === "ok" ? dim(n.text) : yellow(n.text)) + "\n");
9454
9472
  }
9455
9473
  const ct = await import("./cli-token.mjs");
9456
- const st = await ct.readState(join(homedir(), ".gonext"));
9474
+ const st = await ct.readState(join(homedir(), ".gu"));
9457
9475
  void fm.reportSpend({ hostedBase: await freeModelHostedBase(), token: st?.token, state: freeModel });
9458
9476
  } catch {
9459
9477
  /* counting is never worth a broken prompt */
@@ -9474,7 +9492,7 @@ async function runVoucherCommand(line = "/voucher") {
9474
9492
  }
9475
9493
  const ct = await import("./cli-token.mjs");
9476
9494
  const pk = ct.publicKey();
9477
- const dir = join(homedir(), ".gonext");
9495
+ const dir = join(homedir(), ".gu");
9478
9496
  const state = await ct.readState(dir);
9479
9497
  const { DEFAULT_API_BASE } = await import("./device-login.mjs");
9480
9498
  const device = await ct.thisDevice({ instanceId: myInstanceId || "" }).catch(() => null);
@@ -9696,12 +9714,12 @@ async function runPricesUpdate({ tables: given = null, quiet = false } = {}) {
9696
9714
  // "OUTPUT TOKEN LIMITS UPDATED <date>": the cloud token table (GET /api/model-limits, Mongo
9697
9715
  // "model_limits", pushed by the Deploy app's "Push token table to cloud" button) is checked at
9698
9716
  // start and hourly beside the version and price checks. When its updatedAt is newer than the one
9699
- // this machine last saw (~/.gonext/model-limits-seen.json), a clickable item joins the notice
9717
+ // this machine last saw (~/.gu/model-limits-seen.json), a clickable item joins the notice
9700
9718
  // row. Nothing needs applying: the worker reads the cloud table on every run. The click lists
9701
9719
  // what changed and marks it seen.
9702
9720
  // ---------------------------------------------------------------------------------------------
9703
9721
  let limitsUpdate = null; // { updatedAt, label, rows } while unseen changes wait
9704
- const limitsSeenFile = () => join(homedir(), ".gonext", "model-limits-seen.json");
9722
+ const limitsSeenFile = () => join(homedir(), ".gu", "model-limits-seen.json");
9705
9723
 
9706
9724
  async function readLimitsSeen() {
9707
9725
  try {
@@ -9759,7 +9777,7 @@ async function refreshLimitsUpdate() {
9759
9777
  async function markLimitsSeen(updatedAt) {
9760
9778
  try {
9761
9779
  const { mkdir, writeFile } = await import("node:fs/promises");
9762
- await mkdir(join(homedir(), ".gonext"), { recursive: true });
9780
+ await mkdir(join(homedir(), ".gu"), { recursive: true });
9763
9781
  await writeFile(limitsSeenFile(), JSON.stringify({ seenAt: updatedAt }) + "\n");
9764
9782
  } catch {
9765
9783
  /* not remembering only means the notice comes back */
@@ -9893,7 +9911,7 @@ async function runClearLogs() {
9893
9911
  const cl = await import("./clear-logs.mjs");
9894
9912
  const { LOCAL_API_PORT } = await import("./client-expert-api.mjs");
9895
9913
  const width = Math.max(20, process.stdout.columns || 80);
9896
- console.log("\n" + GUTTER + dim("Measuring ~/.gonext…"));
9914
+ console.log("\n" + GUTTER + dim("Measuring ~/.gu…"));
9897
9915
  // Which API version is ANSWERING decides what "old" means — ask it, do not infer it.
9898
9916
  const runningVersion = await fetch(`http://127.0.0.1:${LOCAL_API_PORT}/api/health`, { signal: AbortSignal.timeout(2000) })
9899
9917
  .then((r) => r.json())
@@ -11075,7 +11093,7 @@ const OTHER_AGENTS_MS = 20000;
11075
11093
 
11076
11094
  /**
11077
11095
  * BACKGROUND SHELLS (task #360, GitHub #140). The agent leaves a long command — a 7-minute build —
11078
- * running instead of killing it at its deadline, and records it in ~/.gonext/shells.json. Read
11096
+ * running instead of killing it at its deadline, and records it in ~/.gu/shells.json. Read
11079
11097
  * here once a second (a local file, no API), so the notice row can say it is still running and
11080
11098
  * a click can show it. Repaints only when the row's text changes.
11081
11099
  */
@@ -11222,7 +11240,7 @@ async function browserCleanup() {
11222
11240
  stopBridge();
11223
11241
  await new Promise((res) => setTimeout(res, 300));
11224
11242
  const gone = removeLocalFiles();
11225
- if (gone.length) out(accent(`✓ Deleted ${gone.length} of gu's file(s) in ~/.gonext.`));
11243
+ if (gone.length) out(accent(`✓ Deleted ${gone.length} of gu's file(s) in ~/.gu.`));
11226
11244
  const still = [...findDevInstalls().filter((f) => !(devConnected && f.id === st.id)).map((f) => `${f.browser} — ${f.profile}`), ...localLeftovers()];
11227
11245
  out(still.length ? yellow(`Still there: ${still.join(", ")}`) : accent("✓ The developer install is gone. Install the Chrome Web Store copy, then /browser."));
11228
11246
  out();
@@ -12279,11 +12297,11 @@ const COMPACT_PREFIX = "__COMPACT__::";
12279
12297
  // save the file on this computer. Allow = S3 is now set up AND passed its test.
12280
12298
  const S3SETUP_PREFIX = "__S3SETUP__::";
12281
12299
  // An MCP tool about to run for the first time (task #269): "<server>\t<tool>\t<args preview>".
12282
- // "Always" writes an allow rule to ~/.gonext/mcp.json — the agent re-reads that file before every
12300
+ // "Always" writes an allow rule to ~/.gu/mcp.json — the agent re-reads that file before every
12283
12301
  // call, so it counts from the next call of this same turn, and for every turn after.
12284
12302
  const MCPTOOL_PREFIX = "__MCPTOOL__::";
12285
12303
  // The agent's first use of the browser in a turn (#150): "<folder>\t<what it is about to do>".
12286
- // "Always" puts the folder on ~/.gonext/browser-allow.json, which the agent reads before asking.
12304
+ // "Always" puts the folder on ~/.gu/browser-allow.json, which the agent reads before asking.
12287
12305
  const BROWSER_PREFIX = "__BROWSER__::";
12288
12306
  // GH #540: the agent edited a file whose language has a server gu could use — offer it.
12289
12307
  const LSP_PREFIX = "__LSP__::";
@@ -12362,7 +12380,7 @@ async function approvalPrompt(command) {
12362
12380
  ? " It is already on this computer — nothing to download."
12363
12381
  : lang.tool
12364
12382
  ? ` gu runs \`${lang.tool.what}\` (${size || lang.size}). It is open source (${lang.licence}).`
12365
- : ` gu installs it from npm (${size || lang.size}, into ~/.gonext/lsp — no admin rights). It is open source (${lang.licence}).`;
12383
+ : ` gu installs it from npm (${size || lang.size}, into ~/.gu/lsp — no admin rights). It is open source (${lang.licence}).`;
12366
12384
  process.stdout.write(
12367
12385
  // GH #554: on the gutter like every other line of the turn — it sat two columns to the left.
12368
12386
  "\n" + GUTTER + accent(`${name} code intelligence`) + dim(` (no answer in ${LSP_OFFER_MS / 1000}s = not now)`) + "\n" +
@@ -13095,7 +13113,7 @@ async function tryStartLocalApi() {
13095
13113
  const ce = await import("./client-expert-api.mjs");
13096
13114
  if ((await ce.probeLocalApi()).ok) return true;
13097
13115
  const { readdir } = await import("node:fs/promises");
13098
- const base = join(homedir(), ".gonext", "api");
13116
+ const base = join(homedir(), ".gu", "api");
13099
13117
  const versions = (await readdir(base).catch(() => [])).sort((a, b) =>
13100
13118
  a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" })
13101
13119
  );
@@ -13353,7 +13371,7 @@ function announceScaffold() {
13353
13371
  async function ensureTokenForTurn() {
13354
13372
  if (!isClientExpert()) return true;
13355
13373
  const ct = await import("./cli-token.mjs");
13356
- const dir = join(homedir(), ".gonext");
13374
+ const dir = join(homedir(), ".gu");
13357
13375
  const state = await ct.readState(dir);
13358
13376
  if (!ct.turnNeedsToken({ privateMode: true, token: state.token })) return true;
13359
13377
  // The FALLBACK (#314): the token is normally settled at the first ">>" (askTokenAtStart); this
@@ -13480,7 +13498,7 @@ async function askTokenAtStart() {
13480
13498
  // The background refresh started at launch renews and WRITES the token: let it finish, or it
13481
13499
  // could overwrite a token pasted here with the old one — and its answer is the freshest anyway.
13482
13500
  await startupTokenRefresh?.catch(() => undefined);
13483
- const dir = join(homedir(), ".gonext");
13501
+ const dir = join(homedir(), ".gu");
13484
13502
  const state = await ct.readState(dir);
13485
13503
  if (ct.turnNeedsToken({ privateMode: true, token: state.token })) {
13486
13504
  await askForCliToken(ct, dir);
@@ -15959,7 +15977,7 @@ async function main() {
15959
15977
  dim(`${API_CALL_TIMEOUT_MS / 1000}s, so the API is running and stuck` + (onGudb ? "." : " —")) +
15960
15978
  dim(onGudb ? "\n Check, in this order:" : "\n usually on MongoDB. Check, in this order:") +
15961
15979
  dim("\n gu-cli api status does it answer at all?") +
15962
- dim("\n ~/.gonext/local-api.log what it was doing when it stopped answering") +
15980
+ dim("\n ~/.gu/local-api.log what it was doing when it stopped answering") +
15963
15981
  (onGudb ? "" : dim("\n is mongod running? the API waits on it and never times out itself")) +
15964
15982
  dim("\n Then restart it: gu-cli api stop && gu-cli api start\n")
15965
15983
  );
@@ -15982,7 +16000,7 @@ async function main() {
15982
16000
  started
15983
16001
  ? dim(" Started it — run `gu` again.\n")
15984
16002
  : dim(" Start it with: gu-cli api start") +
15985
- dim("\n If that fails, check MongoDB is running and see ~/.gonext/local-api.log\n")
16003
+ dim("\n If that fails, check MongoDB is running and see ~/.gu/local-api.log\n")
15986
16004
  );
15987
16005
  }
15988
16006
  } else if (err?.code === "KEY_REJECTED") {
@@ -16655,7 +16673,7 @@ async function main() {
16655
16673
  const bv = await import("./budget-view.mjs");
16656
16674
  const ct = await import("./cli-token.mjs");
16657
16675
  const { DEFAULT_API_BASE } = await import("./device-login.mjs");
16658
- const state = await ct.readState(join(homedir(), ".gonext"));
16676
+ const state = await ct.readState(join(homedir(), ".gu"));
16659
16677
  const result = await bv.fetchProvidersBudget({
16660
16678
  apiBase,
16661
16679
  workerKey,
package/gu_browser.py CHANGED
@@ -30,7 +30,7 @@ _EXT_MISS = {"at": 0}
30
30
 
31
31
 
32
32
  def data_dir():
33
- return os.path.join(os.path.expanduser("~"), ".gonext")
33
+ return os.path.join(os.path.expanduser("~"), ".gu")
34
34
 
35
35
 
36
36
  def state_path():
@@ -44,7 +44,7 @@ def seen_path():
44
44
 
45
45
 
46
46
  def extension_dir():
47
- """The folder the user loads into Chrome. A fixed place under ~/.gonext, not the npm package:
47
+ """The folder the user loads into Chrome. A fixed place under ~/.gu, not the npm package:
48
48
  an update moves the package, and Chrome would lose an unpacked extension loaded from there."""
49
49
  return os.environ.get("GU_BROWSER_EXT_DIR") or os.path.join(data_dir(), "browser-extension")
50
50
 
@@ -168,7 +168,7 @@ def install_text(reason="not connected"):
168
168
  return (f"BROWSER NOT AVAILABLE — {reason}. This is a problem in gu's own browser bridge, NOT a "
169
169
  "missing or broken Chrome: do NOT install, reinstall, move or delete any browser. STOP "
170
170
  "and tell the user, with that error: update gu (npm install -g @tiens.nguyen/gu-cli@latest), "
171
- "restart it, and ask again; the bridge's log is ~/.gonext/browser-bridge.log.")
171
+ "restart it, and ask again; the bridge's log is ~/.gu/browser-bridge.log.")
172
172
  no_chrome = "no chrome found" in str(reason).lower()
173
173
  if last_seen().get("installType") == "normal" and not no_chrome:
174
174
  # The Chrome Web Store copy is installed: never point at the developer folder again (#145).
package/gu_free_budget.py CHANGED
@@ -3,7 +3,7 @@
3
3
  gu used to check the free model's allowance only at the START of a turn and count the turn's spend only
4
4
  at its END — so a long turn ran on, well past the allowance, and usually ended in a confusing error.
5
5
 
6
- Now the agent reads what is left (~/.gonext/free-model.json, which gu writes; it never holds the key),
6
+ Now the agent reads what is left (~/.gu/free-model.json, which gu writes; it never holds the key),
7
7
  adds up what THIS turn has spent after every step, and PAUSES before the step that would not fit:
8
8
  the step that ran stays finished (no half-written file), and the turn ends with a plain message the
9
9
  user can act on, then "continue".
@@ -19,7 +19,7 @@ import math
19
19
  import os
20
20
  import time
21
21
 
22
- STATE_FILE = os.path.join("~", ".gonext", "free-model.json")
22
+ STATE_FILE = os.path.join("~", ".gu", "free-model.json")
23
23
 
24
24
 
25
25
  def _whole(n) -> int:
@@ -147,18 +147,20 @@ def load(coder_url: str, coder_model: str, path: str | None = None):
147
147
  return None
148
148
 
149
149
 
150
- PAUSE_HEAD = ("Paused: this month's free-model allowance is used up, so I stopped before the next step. "
151
- "The steps that ran are finished; nothing was left half-done.")
152
- PAUSE_WAYS = ("To keep going, add your own model key with /model, a local model with Ollama, or a new "
150
+ # GH #579: said ONCE, as the answer's first line — gu shows a first line starting "Paused — " in the warning
151
+ # colour. (A "Pausing — …" step line used to say the same just above it.)
152
+ PAUSE_HEAD = "Paused — this month's free-model allowance is used up."
153
+ PAUSE_WAYS = ("I stopped before the next step; the steps that ran are finished, nothing was left half-done. "
154
+ "To keep going, add your own model key with /model, a local model with Ollama, or a new "
153
155
  "code with /voucher, then type continue. The free model renews on the 1st.")
154
- OUT_OF_CREDIT = ("Paused: the free model can't take more requests right now (its account is out of credit; "
155
- "this is not your allowance). The steps that ran are finished.")
156
+ OUT_OF_CREDIT = ("Paused — the free model can't take more requests right now (its account is out of credit; "
157
+ "this is not your allowance).")
156
158
 
157
159
 
158
160
  def pause_message(recap: str = "", out_of_credit: bool = False) -> str:
159
161
  head = OUT_OF_CREDIT if out_of_credit else PAUSE_HEAD
160
- ways = ("Add your own model key with /model, or a local model with Ollama, then type continue."
161
- if out_of_credit else PAUSE_WAYS)
162
+ ways = ("The steps that ran are finished. Add your own model key with /model, or a local model with Ollama, "
163
+ "then type continue." if out_of_credit else PAUSE_WAYS)
162
164
  body = [head, "", ways]
163
165
  if recap.strip():
164
166
  body += ["", recap.strip()]
package/gu_gif.py CHANGED
@@ -17,7 +17,7 @@ HOLD_MS = 1800 # the first and last frames, so it starts and ends steadily
17
17
 
18
18
 
19
19
  def recordings_dir(home=None):
20
- return os.path.join(home or os.path.expanduser("~"), ".gonext", "recordings")
20
+ return os.path.join(home or os.path.expanduser("~"), ".gu", "recordings")
21
21
 
22
22
 
23
23
  def gif_name(label="", now=None):
package/gu_hooks.py CHANGED
@@ -249,7 +249,7 @@ class HookRunner:
249
249
  # ---- onStart: once per session ---------------------------------------------------------------
250
250
 
251
251
  def _state_path() -> str:
252
- return os.path.join(os.path.expanduser("~"), ".gonext", "hooks-state.json")
252
+ return os.path.join(os.path.expanduser("~"), ".gu", "hooks-state.json")
253
253
 
254
254
 
255
255
  def is_new_session(cwd: str, session_id: str, path: str | None = None) -> bool:
package/gu_mcp.py CHANGED
@@ -27,6 +27,7 @@ import json
27
27
  import os
28
28
  import queue
29
29
  import re
30
+ import shutil
30
31
  import subprocess
31
32
  import sys
32
33
  import threading
@@ -55,6 +56,23 @@ def server_env(extra: dict | None) -> dict:
55
56
  return env
56
57
 
57
58
 
59
+ # GH #577: interpreters an MCP config may name by FULL path. That path is often a versioned folder
60
+ # (/opt/homebrew/Cellar/node/26.12.0/bin/node, ~/.nvm/versions/node/v22.x/bin/node) that an upgrade deletes.
61
+ _INTERPRETERS = {"node", "node.exe", "npx", "npx.cmd", "python", "python3", "python.exe", "uv", "uvx", "bun", "deno"}
62
+
63
+
64
+ def resolve_command(command: str, path: str | None = None) -> str:
65
+ """The command to start: as saved, unless it is a full path to an interpreter that is GONE — then the same
66
+ program found on PATH. Anything else is left exactly as saved (a missing custom binary still says so)."""
67
+ if command and os.path.isabs(command) and not os.path.exists(command):
68
+ base = os.path.basename(command)
69
+ if base.lower() in _INTERPRETERS:
70
+ found = shutil.which(base, path=path)
71
+ if found:
72
+ return found
73
+ return command
74
+
75
+
58
76
  class McpError(Exception):
59
77
  """A server that could not be reached or answered with an error — the message says which."""
60
78
 
@@ -77,10 +95,12 @@ class StdioMcpClient:
77
95
 
78
96
  # ---- process ----------------------------------------------------------------------------
79
97
  def start(self) -> None:
98
+ env = server_env(self.env)
99
+ command = resolve_command(self.command, env.get("PATH"))
80
100
  try:
81
101
  self.proc = subprocess.Popen(
82
- [self.command, *self.args], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
83
- stderr=subprocess.PIPE, cwd=self.cwd, env=server_env(self.env),
102
+ [command, *self.args], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
103
+ stderr=subprocess.PIPE, cwd=self.cwd, env=env,
84
104
  text=True, encoding="utf-8", errors="replace", bufsize=1,
85
105
  )
86
106
  except FileNotFoundError:
package/gu_turn_notes.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """NOTES TYPED DURING A TURN, read by the running agent at its next step (GH #506).
2
2
 
3
- gu writes what the user typed while a turn runs to ~/.gonext/turn-notes/<jobId>.jsonl. The agent's
3
+ gu writes what the user typed while a turn runs to ~/.gu/turn-notes/<jobId>.jsonl. The agent's
4
4
  step callback TAKES the file (rename, then read) after a step and adds the notes to that step's
5
5
  observations — the newest text of the conversation, not yet sent to the model. So the prompt is only
6
6
  APPENDED to: the system prompt, the tool reference and every earlier step stay byte-identical, and
@@ -25,7 +25,7 @@ NOTE_TAIL = ("Answer it FIRST, in one short line, with say(\"...\") — what you
25
25
 
26
26
 
27
27
  def notes_dir() -> str:
28
- return os.path.join(os.path.expanduser("~"), ".gonext", "turn-notes")
28
+ return os.path.join(os.path.expanduser("~"), ".gu", "turn-notes")
29
29
 
30
30
 
31
31
  def _safe(job_id: str) -> str: