@hexdecimal16/nexo 0.2.0 → 0.2.1

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/cli/src/common.js CHANGED
@@ -6,6 +6,7 @@ export const USAGE = `Usage:
6
6
  without --workspace each turn works in its own run folder (files carried over
7
7
  from the previous turn); --workspace . works in the current folder
8
8
  nexo sessions [--limit <n>]
9
+ nexo --version print the installed version
9
10
  nexo settings open the settings screen (needs a terminal)
10
11
  nexo settings get <key>
11
12
  nexo settings set <key> <value> keys: models.s1|s2|judge|reflector|embedding, budgets.*, tools.policy.*, tools.autoApprove, tools.nonInteractiveAsk, models.approver, scoring.judge, learning.*, memory.*, optimize.minCases|patience|minJudgeKappa|noveltySimilarity|offspringAlpha
package/cli/src/main.js CHANGED
@@ -15,6 +15,7 @@ import { interactiveCommand, settingsScreenCommand } from "./interactive.js";
15
15
  import { sessionsCommand } from "./sessions.js";
16
16
  import { doctorCommand } from "./doctor.js";
17
17
  import { initCommand } from "./init.js";
18
+ import { nexoVersion } from "./version.js";
18
19
  import { settingsCommand } from "./settings.js";
19
20
  import { escapeControl } from "../../tui/src/index.js";
20
21
  import { runUi } from "./ui.js";
@@ -210,7 +211,7 @@ export async function runCli(argv, io, options = {}) {
210
211
  const [command, ...rest] = argv;
211
212
  const stdio = options.stdio ?? process;
212
213
  try {
213
- if (command === undefined || (command.startsWith("-") && command !== "--help" && command !== "-h")) {
214
+ if (command === undefined || (command.startsWith("-") && command !== "--help" && command !== "-h" && command !== "--version" && command !== "-v")) {
214
215
  return await interactiveCommand(argv, io, options, stdio);
215
216
  }
216
217
  switch (command) {
@@ -247,6 +248,10 @@ export async function runCli(argv, io, options = {}) {
247
248
  case "-h":
248
249
  io.stdout.write(USAGE);
249
250
  return 0;
251
+ case "--version":
252
+ case "-v":
253
+ io.stdout.write(`${nexoVersion()}\n`);
254
+ return 0;
250
255
  default:
251
256
  throw usageError(`Unknown command "${command}"`);
252
257
  }
@@ -0,0 +1,19 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ /**
4
+ * nexo's version. In the repo it is packages/cli/package.json (one level above src); in the published package the
5
+ * compiled file sits in cli/src and the package.json is at the package root (two levels above).
6
+ */
7
+ export function nexoVersion() {
8
+ for (const relative of ["../package.json", "../../package.json"]) {
9
+ try {
10
+ const json = JSON.parse(readFileSync(fileURLToPath(new URL(relative, import.meta.url)), "utf8"));
11
+ if (typeof json.version === "string")
12
+ return json.version;
13
+ }
14
+ catch {
15
+ // not at this location; try the next one
16
+ }
17
+ }
18
+ return "unknown";
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexdecimal16/nexo",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "nexo agent engine",
5
5
  "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "repository": {
package/tui/src/app.js CHANGED
@@ -24,6 +24,8 @@ function filesLine(session) {
24
24
  return `files: ${escapeControl(tildePath(session.runsDir))}/<turn id>/workspace (carried over each turn)`;
25
25
  }
26
26
  const DOUBLE_CTRL_C_MS = 1000;
27
+ /** Two Esc presses within this window on an idle prompt clear the draft (and keep it in history). */
28
+ const DOUBLE_ESC_MS = 800;
27
29
  /** Last lines of a `!` command's output shown in the chat (the model gets more). */
28
30
  const SHELL_SCREEN_LINES = 200;
29
31
  /** Time given to paint the "opening…" footer before the synchronous session open blocks the loop (one render interval and a margin). */
@@ -127,6 +129,7 @@ class InteractiveApp {
127
129
  tickTimer = null;
128
130
  loader = null;
129
131
  lastCtrlC = Number.NEGATIVE_INFINITY;
132
+ lastEscape = Number.NEGATIVE_INFINITY;
130
133
  defaultModel = "";
131
134
  /** Model and effort of the running turn's root run, from its run_start and escalation events; null between turns. */
132
135
  liveModel = null;
@@ -361,6 +364,20 @@ class InteractiveApp {
361
364
  this.turnAbort?.abort();
362
365
  return { consume: true };
363
366
  }
367
+ if (matchesKey(data, "escape") && !this.running && this.screen === "chat" && this.session && !this.editor.isShowingAutocomplete()) {
368
+ // Idle prompt, like Claude Code: a second Esc clears the draft but saves it to history, so Up brings it back.
369
+ const text = this.editor.getText();
370
+ const now = this.now();
371
+ if (text.trim() !== "" && now - this.lastEscape <= DOUBLE_ESC_MS) {
372
+ this.editor.addToHistory(text.trim());
373
+ this.editor.setText("");
374
+ this.lastEscape = Number.NEGATIVE_INFINITY;
375
+ this.tui.requestRender();
376
+ return { consume: true };
377
+ }
378
+ this.lastEscape = text.trim() !== "" ? now : Number.NEGATIVE_INFINITY;
379
+ return undefined;
380
+ }
364
381
  if (matchesKey(data, "ctrl+o") && this.screen === "chat") {
365
382
  if (isKeyRepeat(data))
366
383
  return { consume: true };
@@ -33,6 +33,6 @@ export function helpText() {
33
33
  const width = Math.max(...SLASH_COMMANDS.map((c) => `/${c.name}${c.argumentHint ? ` ${c.argumentHint}` : ""}`.length));
34
34
  const lines = SLASH_COMMANDS.map((c) => `${`/${c.name}${c.argumentHint ? ` ${c.argumentHint}` : ""}`.padEnd(width)} ${c.description ?? ""}`);
35
35
  lines.push("", `${"!<command>".padEnd(width)} Run a shell command; its output goes to the model with your next message`);
36
- lines.push("", "enter send · shift+enter newline · ↑↓ history · ctrl+o expand tool output · esc/ctrl-c stop a turn · ctrl-c twice or ctrl-d quit");
36
+ lines.push("", "enter send · shift+enter newline · ↑↓ history · ctrl+o expand tool output · esc/ctrl-c stop a turn · esc twice clears the draft (↑ recalls it) · ctrl-c twice or ctrl-d quit");
37
37
  return lines.join("\n");
38
38
  }