@tiens.nguyen/gu-cli 1.0.922 → 1.0.925

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.
@@ -224,6 +224,16 @@ export function embedNotice({ state, model } = {}) {
224
224
  return "no embed model — RAG is off · /embed-model";
225
225
  }
226
226
 
227
+ /**
228
+ * AN OPEN WINDOW ON OLD CODE (GH #513): the gu on disk has another version than the one this window started
229
+ * with (a deploy, /update elsewhere, npm). Say so — never restart the window: what is on screen would go.
230
+ */
231
+ export function versionNoticeRows(running, onDisk) {
232
+ const known = (v) => /^\d+\.\d+\.\d+/.test(String(v ?? ""));
233
+ if (!known(running) || !known(onDisk) || running === onDisk) return [];
234
+ return [`gu ${onDisk} is on this computer — Ctrl+C, then gu, to use it`];
235
+ }
236
+
227
237
  /**
228
238
  * WHICH SETUP ROWS THE BOTTOM BAR SHOWS (first-run noise, #188). A fresh install used to stack
229
239
  * three warnings at once. Now they come in order of need, and pure (no OS-specific logic):
@@ -13559,7 +13559,8 @@ def run_agent_chat(cfg):
13559
13559
  import gu_turn_notes as _turn_notes
13560
13560
  _n = _turn_notes.add_to_step(step_log, _job_id)
13561
13561
  if _n:
13562
- _emit({"type": "step", "text": f"Read your note{'s' if _n > 1 else ''} — taking {'them' if _n > 1 else 'it'} into account"})
13562
+ # GH #514: a marker, not a message — gu moves the user's own words into the history here.
13563
+ _emit({"type": "step", "text": f"__USERNOTE__::{_n}"})
13563
13564
  _log(f"step {step_num}: {_n} user note(s) added for the next step")
13564
13565
  except Exception as e: # noqa: BLE001
13565
13566
  _log(f"user note skip: {e}")
package/gu-repl.mjs CHANGED
@@ -157,12 +157,12 @@ import { readHooks } from "./hooks-config.mjs";
157
157
  import { readSkillSource, sourceLabel, SKILL_SOURCE_KEY } from "./skill-source.mjs";
158
158
  import { codingBannerLabel, isOllamaCloudUrl, SECRET_KEY_HINT } from "./coding-key-prompt.mjs";
159
159
  import { questionEchoText, thoughtPrintSeq, wrapDiffText } from "./terminal-layout.mjs";
160
- import { createTurnQueue, queuedNotice, typingNotice, droppedNote } from "./turn-queue.mjs"; // GH #429: questions typed during a turn wait here
161
- import { sendNote, takeUnread, sweepOldNotes, sentNotice, SENT_NOTE } from "./turn-notes.mjs"; // GH #506: …or go to the running turn
160
+ import { createTurnQueue, droppedNote } from "./turn-queue.mjs"; // GH #429: questions typed during a turn wait here
161
+ import { sendNote, takeUnread, sweepOldNotes, parseUserNote, questionWithNotes, USERNOTE_PREFIX } from "./turn-notes.mjs"; // GH #506: …or go to the running turn
162
162
  import { globalPrefixOf } from "./install-path.mjs";
163
163
  import { indentBlock, commandBlockRows, wrapIndented } from "./terminal-layout.mjs"; // every line of an Allow-prompt detail indented (#189); wrapped + collapsible command (#204)
164
164
  import { firstGuOnPath, pathGuMismatch, guOnPathIsCurrent, updateAttemptRecord, repeatUpdateNotice } from "./update-verify.mjs";
165
- import { embedNotice, embedState, setupNoticeRows } from "./embed-model-command.mjs";
165
+ import { embedNotice, embedState, setupNoticeRows, versionNoticeRows } from "./embed-model-command.mjs";
166
166
  import { createConnectionWatch, modelHostsOf, offlineLine, probeReachable, stalledLine } from "./connection-watch.mjs";
167
167
  import { HINTS, pickHint, hintRow, hintFits, HINT_AFTER_SECONDS } from "./hints.mjs";
168
168
  import { normalizeQuick, quickReady, quickTarget, quickBarHint, quickWarning, QUICK_MAX } from "./quick-models.mjs";
@@ -239,6 +239,19 @@ const REPL_VERSION = (() => {
239
239
  return "unknown";
240
240
  }
241
241
  })();
242
+ // The version on disk NOW, looked at every 20 s (GH #513). Unreadable (npm half-way through) → keep the last.
243
+ let diskVersion = REPL_VERSION;
244
+ setInterval(() => {
245
+ try {
246
+ const v = JSON.parse(readFileSync(join(DIR, "package.json"), "utf8")).version;
247
+ if (v && v !== diskVersion) {
248
+ diskVersion = v;
249
+ if (barPinned()) paintBar();
250
+ }
251
+ } catch {
252
+ /* try again next time */
253
+ }
254
+ }, 20_000).unref();
242
255
  const ENV_FILE = join(homedir(), ".gonext", "worker.env");
243
256
  const WS_FILE = join(homedir(), ".gonext", "workspaces.json");
244
257
  const SESSIONS_DIR = join(homedir(), ".gonext", "sessions");
@@ -1240,6 +1253,27 @@ function pendingEchoRows() {
1240
1253
  if (lines.length > 3) shown.push(dim(`${GUTTER}… ${lines.length - 3} more line(s)`));
1241
1254
  return [...shown, ""];
1242
1255
  }
1256
+ /** A message typed during a turn, drawn as every asked question is (GH #514). */
1257
+ function pastQuestion(text) {
1258
+ return questionEchoText(imageMarkersForDisplay(text), {
1259
+ width: process.stdout.columns || 80,
1260
+ paintPrompt: () => PROMPT_PAST,
1261
+ }) + "\n";
1262
+ }
1263
+ /** What waits for the agent, above the input box: dim ">> " rows, at most 3 lines each and 6 in all. */
1264
+ function waitingNoteRows() {
1265
+ if (!following) return [];
1266
+ const width = Math.max(20, process.stdout.columns || 80);
1267
+ const texts = [...waitingNotes.filter((n) => !n.shown).map((n) => n.text), ...turnQueue.list()];
1268
+ const rows = [];
1269
+ for (const t of texts) {
1270
+ const lines = pastQuestion(t).replace(/\n+$/, "").split("\n").map((l) => stripAnsiEscapes(l));
1271
+ rows.push(...lines.slice(0, 3).map((l) => dim(clipVisible(l, width - 1))));
1272
+ if (lines.length > 3) rows.push(dim(`${GUTTER}… ${lines.length - 3} more line(s)`));
1273
+ }
1274
+ if (!rows.length) return [];
1275
+ return ["", ...(rows.length > 6 ? [...rows.slice(0, 5), dim(`${GUTTER}… ${rows.length - 5} more line(s) waiting`)] : rows)];
1276
+ }
1243
1277
  function flushPendingEcho() {
1244
1278
  if (pendingEcho === null) return;
1245
1279
  const text = pendingEcho;
@@ -2211,18 +2245,17 @@ rl.on("line", (l) => {
2211
2245
  turnTyping.reset();
2212
2246
  // GH #506: with a running job, the text goes to the agent's NEXT step (appended after the
2213
2247
  // current step's result — cache-safe). Not read by the end of the turn = the next question.
2248
+ // GH #514: like chat — no notices. Pinned, it waits as a ">> " row above the input box until the agent
2249
+ // reads it; with no frozen rows (piped, a tiny window) it is written into the history at once.
2214
2250
  if (queued && currentJobId && !cancelRequested && sendNote(currentJobId, queued)) {
2215
- notesSent += 1;
2216
- // Pinned: the input row says it (a line written mid-turn would break the zone, #321).
2251
+ waitingNotes.push({ text: queued, shown: !barPinned() });
2217
2252
  if (barPinned()) paintBar();
2218
- else process.stdout.write(dim(`\n ${SENT_NOTE}\n`));
2253
+ else process.stdout.write("\n" + pastQuestion(queued) + "\n");
2219
2254
  return;
2220
2255
  }
2221
2256
  if (queued) {
2222
2257
  if (turnQueue.push(queued)) {
2223
- // No frozen row to carry the count (piped, or a window too short to pin one): say it here.
2224
2258
  if (barPinned()) paintBar();
2225
- else process.stdout.write(dim(`\n (queued — ${turnQueue.size} waiting; runs when this turn finishes)\n`));
2226
2259
  } else {
2227
2260
  process.stdout.write(dim(`\n (${turnQueue.size} questions are already queued — wait for one to run)\n`));
2228
2261
  }
@@ -3091,7 +3124,8 @@ const footerBuilt = () =>
3091
3124
  // Task #14: the skipped-setup warning — persistent (not a timed notice), red, its own row.
3092
3125
  // …then the fallback rows (#343), YELLOW: a different model is doing the work — a warning,
3093
3126
  // where the red rows above mean something is not set up at all.
3094
- missing: [...missingNoticeRows().map((r) => red(r)), ...fallbackNoticeRows().map((r) => yellow(r))],
3127
+ // …and (GH #513), yellow too: this window runs older code than the gu now on this computer.
3128
+ missing: [...missingNoticeRows().map((r) => red(r)), ...fallbackNoticeRows().map((r) => yellow(r)), ...versionNoticeRows(REPL_VERSION, diskVersion).map((r) => yellow(r))],
3095
3129
  });
3096
3130
  const footerRows = () => footerBuilt().rows;
3097
3131
  // An ask()'s hint lines (#305), drawn in yellow under its input while it waits. Plain text.
@@ -3252,7 +3286,7 @@ function closeZonePanel() {
3252
3286
  function frozenZone() {
3253
3287
  const width = Math.max(20, process.stdout.columns || 80);
3254
3288
  if (zonePanel) {
3255
- const status = footerActive ? [] : [...pendingEchoRows(), ...liveStatusRows];
3289
+ const status = footerActive ? [] : [...pendingEchoRows(), ...liveStatusRows, ...waitingNoteRows()];
3256
3290
  // At least four rows of conversation stay visible, as with a tall input (maxInputRows).
3257
3291
  const room = Math.max(3, viewportRows() - status.length - 2 - 4);
3258
3292
  let body = [];
@@ -3275,7 +3309,7 @@ function frozenZone() {
3275
3309
  // statusShown is already false — the prompt simply refuses to render any.
3276
3310
  // #307: a question held until its turn prints anything sits on top of the status block — where
3277
3311
  // it will land once committed, so nothing moves when it does.
3278
- const status = footerActive ? [] : [...pendingEchoRows(), ...liveStatusRows];
3312
+ const status = footerActive ? [] : [...pendingEchoRows(), ...liveStatusRows, ...waitingNoteRows()];
3279
3313
  // THE SEPARATOR CARRIES NOTHING (#318). What used to ride on it — jump-to-bottom, the update
3280
3314
  // control, the gu token notice, the agents count — is on its own NOTICE ROW above it; the head
3281
3315
  // is just the rule, with no blank to lift a control off the typed line.
@@ -11624,11 +11658,7 @@ const turnRowNotice = (width) =>
11624
11658
  ? cancelRequested
11625
11659
  ? visibleLen(SUPPORT_AFTER_STOP_NOTICE) + 12 <= width ? SUPPORT_AFTER_STOP_NOTICE : SUPPORT_AFTER_STOP_SHORT
11626
11660
  : visibleLen(SUPPORT_AFTER_TURN_NOTICE) + 12 <= width ? SUPPORT_AFTER_TURN_NOTICE : SUPPORT_AFTER_TURN_SHORT
11627
- : typedDuringTurn
11628
- ? typingNotice(width)
11629
- : notesSent
11630
- ? sentNotice(notesSent, width)
11631
- : queuedNotice(turnQueue.size, width);
11661
+ : "";
11632
11662
  // Is the turn we are following one this terminal STARTED, or another terminal's that we merely
11633
11663
  // attached to (task #211)? `attached` is local to runAgentTurn, and onInterrupt — which lives in
11634
11664
  // main() — had no way to ask. So Ctrl+C while watching somebody else's agent took the "cancel my
@@ -11636,7 +11666,9 @@ const turnRowNotice = (width) =>
11636
11666
  // non-destructive way back to your own prompt, which is the bug this flag exists to fix.
11637
11667
  let followingAttached = false;
11638
11668
  let followAborted = false;
11639
- let notesSent = 0; // GH #506: notes handed to the running turn (the input row says so)
11669
+ // GH #506/#514: what was typed during this turn — waiting for the agent, and what it has read.
11670
+ let waitingNotes = []; // {text, shown} — shown: already in the history (unpinned)
11671
+ let readNotes = []; // texts the agent read, kept with this turn's question
11640
11672
  let currentJobId = null; // the running turn's jobId — so Ctrl+C can cancel it server-side
11641
11673
  let cancelRequested = false; // a cancel POST has been sent for the current turn
11642
11674
  // Interactive command-approval gate: while the agent is paused on a risky command, the
@@ -13836,6 +13868,22 @@ async function runAgentTurn(history, { attachJobId = "", ownJob = false } = {})
13836
13868
  // Task #343: another model took over. Swallowed from the action list — it goes on the
13837
13869
  // BAR, now, in yellow — and the turn leaves one line about it once it has ended (see the
13838
13870
  // caller), so a fallback that lasted a single step can still be found afterwards.
13871
+ // GH #514: the agent just read what was typed — it becomes part of the history HERE, between its steps.
13872
+ if (line.startsWith(USERNOTE_PREFIX)) {
13873
+ const taken = waitingNotes.splice(0, parseUserNote(line));
13874
+ if (taken.length) {
13875
+ readNotes.push(...taken.map((n) => n.text));
13876
+ const unseen = taken.filter((n) => !n.shown);
13877
+ if (unseen.length) {
13878
+ releaseHeldThought();
13879
+ onContent();
13880
+ process.stdout.write((lastWasBlank ? "" : "\n") + unseen.map((n) => pastQuestion(n.text)).join("\n") + "\n");
13881
+ lastWasBlank = true;
13882
+ }
13883
+ }
13884
+ lastContentAt = Date.now();
13885
+ continue;
13886
+ }
13839
13887
  if (line.startsWith(MODELFALLBACK_PREFIX)) {
13840
13888
  const fb = parseModelFallback(line);
13841
13889
  if (fb) {
@@ -14486,7 +14534,7 @@ async function runAgentTurn(history, { attachJobId = "", ownJob = false } = {})
14486
14534
  }
14487
14535
  }
14488
14536
  currentJobId = null;
14489
- notesSent = 0;
14537
+ waitingNotes = [];
14490
14538
  // Drop anything typed (but not submitted) during the turn — echo was muted, so it's
14491
14539
  // invisible; without this it would surface on the next prompt.
14492
14540
  rl.line = "";
@@ -16228,6 +16276,7 @@ async function main() {
16228
16276
  // another model's price on it.
16229
16277
  const turnCoder = { url: activeCodingUrl(), model: activeCodingModelId() };
16230
16278
  turnFallback = null; // #343: nothing has fallen back in THIS turn yet
16279
+ readNotes = []; // #514
16231
16280
  if (reattach) console.log(GUTTER + dim("following the turn that was running when the connection went…\n"));
16232
16281
  const turn = await runAgentTurn(history, reattach ? { attachJobId: reattach.jobId, ownJob: true } : {});
16233
16282
  // NOT SENT (licence block, or the token prompt declined): runAgentTurn already said so.
@@ -16286,6 +16335,9 @@ async function main() {
16286
16335
  if (fellBack) printFallbackLine(fellBack);
16287
16336
  } else if (answer) {
16288
16337
  noteTaskSuccess();
16338
+ // GH #514: the next turns know what was added while this one ran.
16339
+ const asked = history[history.length - 1];
16340
+ if (readNotes.length && asked?.role === "user") asked.content = questionWithNotes(asked.content, readNotes);
16289
16341
  history.push({ role: "assistant", content: answer });
16290
16342
  // Persist after every successful turn (not just on clean exit) — an ungraceful
16291
16343
  // termination (killed terminal, force-quit) would otherwise lose the whole
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gu-cli",
3
- "version": "1.0.922",
3
+ "version": "1.0.925",
4
4
  "description": "gu: the coding agent in your terminal. It reads your repo, makes the change and runs the tests, with your own models (Ollama or any OpenAI-compatible provider). Free installs keep the agent, its API and its database on your machine. macOS, Linux and Windows.",
5
5
  "keywords": [
6
6
  "ai",
package/turn-notes.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // NOTES FOR THE RUNNING TURN (GH #506).
1
+ // NOTES FOR THE RUNNING TURN (GH #506, shown like chat messages since #514).
2
2
  //
3
3
  // Enter during a turn used to QUEUE the question for after the turn (#429). Now it is written to
4
4
  // ~/.gonext/turn-notes/<jobId>.jsonl, and the agent (gu_turn_notes.py) adds it after its current
@@ -67,11 +67,23 @@ export function sweepOldNotes(home, now = Date.now()) {
67
67
  }
68
68
  }
69
69
 
70
- /** The line under the input row after Enter. */
71
- export const SENT_NOTE = "↳ sent to the running turn — the agent reads it at its next step";
70
+ /**
71
+ * IT LOOKS LIKE CHATTING (GH #514) — no notices. On Enter the message waits as a ">> …" row above the input
72
+ * box; when the agent reads it, it reports `__USERNOTE__::<count>` as a step, and gu moves that many rows into
73
+ * the history at that very point, drawn like any question.
74
+ */
75
+ export const USERNOTE_PREFIX = "__USERNOTE__::";
72
76
 
73
- /** The input-row label after notes were sent during this turn. */
74
- export function sentNotice(n, width = 80) {
75
- const long = `(${n === 1 ? "note" : `${n} notes`} sent — the agent reads ${n === 1 ? "it" : "them"} at its next step) `;
76
- return long.length + 12 <= width ? long : `(${n === 1 ? "note" : `${n} notes`} sent) `;
77
+ /** → how many notes the agent just read; 0 when the line is not that report. */
78
+ export function parseUserNote(line) {
79
+ const s = String(line ?? "").trim();
80
+ if (!s.startsWith(USERNOTE_PREFIX)) return 0;
81
+ const n = Number(s.slice(USERNOTE_PREFIX.length));
82
+ return Number.isInteger(n) && n > 0 ? n : 0;
83
+ }
84
+
85
+ /** The turn's question as the next turns see it: what was added while it ran belongs to it. */
86
+ export function questionWithNotes(question, notes) {
87
+ const added = (notes ?? []).map((t) => String(t).trim()).filter(Boolean);
88
+ return added.length ? `${question}\n\n[Added by the user while you were working]\n${added.join("\n\n")}` : question;
77
89
  }
package/turn-queue.mjs CHANGED
@@ -6,12 +6,6 @@
6
6
 
7
7
  export const MAX_QUEUED_QUESTIONS = 20;
8
8
 
9
- /** What the input row says while the user is typing during a turn. */
10
- // GH #506: Enter now hands the text to the RUNNING turn (turn-notes.mjs); the queue below keeps what
11
- // the agent did not read before the turn ended.
12
- export const TYPING_NOTICE = "(turn running — Enter sends it to the agent's next step) ";
13
- export const TYPING_SHORT = "(Enter sends it) ";
14
-
15
9
  export function createTurnQueue({ max = MAX_QUEUED_QUESTIONS } = {}) {
16
10
  const items = [];
17
11
  return {
@@ -29,6 +23,10 @@ export function createTurnQueue({ max = MAX_QUEUED_QUESTIONS } = {}) {
29
23
  items.unshift(...take);
30
24
  return take.length;
31
25
  },
26
+ /** The waiting items, oldest first (GH #514: shown above the input box). */
27
+ list() {
28
+ return [...items];
29
+ },
32
30
  shift() {
33
31
  return items.length ? items.shift() : null;
34
32
  },
@@ -44,20 +42,6 @@ export function createTurnQueue({ max = MAX_QUEUED_QUESTIONS } = {}) {
44
42
  };
45
43
  }
46
44
 
47
- const fits = (s, width) => s.length + 12 <= width;
48
-
49
- /** The input-row label while questions wait and nothing is being typed; "" when the queue is empty. */
50
- export function queuedNotice(n, width = 80) {
51
- if (!n) return "";
52
- const long = `(${n} queued — runs after this turn; Ctrl-C drops them) `;
53
- return fits(long, width) ? long : `(${n} queued) `;
54
- }
55
-
56
- /** The typing label that fits the row. */
57
- export function typingNotice(width = 80) {
58
- return fits(TYPING_NOTICE, width) ? TYPING_NOTICE : TYPING_SHORT;
59
- }
60
-
61
45
  /** One line for the transcript when queued questions are thrown away. */
62
46
  export function droppedNote(n) {
63
47
  return `(${n} queued question${n === 1 ? "" : "s"} not run — the turn did not finish; type ${n === 1 ? "it" : "them"} again)`;