nexrall-code 0.5.35 → 0.5.37

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 (2) hide show
  1. package/dist/index.js +86 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -62092,6 +62092,69 @@ var import_react32 = __toESM(require_react(), 1);
62092
62092
  // ../../node_modules/.pnpm/ink@7.1.1_@types+react@19.2.18_react@19.2.8/node_modules/ink/build/hooks/use-box-metrics.js
62093
62093
  var import_react33 = __toESM(require_react(), 1);
62094
62094
 
62095
+ // src/ui/imeBuffer.ts
62096
+ function isImeLikeInput(input) {
62097
+ if (!input)
62098
+ return false;
62099
+ if (input.length === 1 && input.charCodeAt(0) < 128)
62100
+ return false;
62101
+ if (Buffer.byteLength(input, "utf8") > input.length)
62102
+ return true;
62103
+ if (/[\u0300-\u036F]/.test(input))
62104
+ return true;
62105
+ return false;
62106
+ }
62107
+ var ImeCompositionBuffer = class {
62108
+ buf = "";
62109
+ timer = null;
62110
+ timeoutMs;
62111
+ onFlush;
62112
+ constructor(options) {
62113
+ this.timeoutMs = options.timeoutMs ?? 50;
62114
+ this.onFlush = options.onFlush;
62115
+ }
62116
+ /** Buffer a chunk of IME-like input, (re)starting the auto-flush timer. */
62117
+ add(chunk) {
62118
+ this.buf += chunk;
62119
+ this.restartTimer();
62120
+ }
62121
+ /** Remove the last character from the buffer (used for IME backspace). */
62122
+ backspace() {
62123
+ if (!this.buf)
62124
+ return false;
62125
+ this.buf = this.buf.slice(0, -1);
62126
+ this.restartTimer();
62127
+ return true;
62128
+ }
62129
+ hasContent() {
62130
+ return this.buf.length > 0;
62131
+ }
62132
+ /** Flush immediately (used when an unambiguous non-IME key arrives). */
62133
+ flush() {
62134
+ this.clearTimer();
62135
+ if (!this.buf)
62136
+ return;
62137
+ const text = this.buf;
62138
+ this.buf = "";
62139
+ this.onFlush(text);
62140
+ }
62141
+ /** Cancel the timer without flushing (used on unmount). */
62142
+ destroy() {
62143
+ this.clearTimer();
62144
+ this.buf = "";
62145
+ }
62146
+ restartTimer() {
62147
+ this.clearTimer();
62148
+ this.timer = setTimeout(() => this.flush(), this.timeoutMs);
62149
+ }
62150
+ clearTimer() {
62151
+ if (this.timer !== null) {
62152
+ clearTimeout(this.timer);
62153
+ this.timer = null;
62154
+ }
62155
+ }
62156
+ };
62157
+
62095
62158
  // src/ui/inkTerminal.tsx
62096
62159
  function footerText(info) {
62097
62160
  const modeLabel = info.autoApprove ? "yolo mode on" : info.mode === "plan" ? "plan mode on" : info.mode === "edit" ? "edit mode on" : info.mode === "ask" ? "ask mode on" : "auto mode on";
@@ -62130,6 +62193,16 @@ var App2 = ({ onReady }) => {
62130
62193
  const onLine = (0, import_react34.useCallback)((cb) => {
62131
62194
  onLineRef.current = cb;
62132
62195
  }, []);
62196
+ const imeBufferRef = (0, import_react34.useRef)(null);
62197
+ if (imeBufferRef.current === null) {
62198
+ imeBufferRef.current = new ImeCompositionBuffer({
62199
+ onFlush: (text) => setLine((s2) => s2 + text)
62200
+ });
62201
+ }
62202
+ import_react34.default.useEffect(() => {
62203
+ const buf = imeBufferRef.current;
62204
+ return () => buf?.destroy();
62205
+ }, []);
62133
62206
  use_input_default((char, key) => {
62134
62207
  if (!inputEnabled)
62135
62208
  return;
@@ -62138,10 +62211,15 @@ var App2 = ({ onReady }) => {
62138
62211
  return;
62139
62212
  }
62140
62213
  if (key.backspace || key.delete) {
62214
+ if (imeBufferRef.current?.hasContent()) {
62215
+ imeBufferRef.current.backspace();
62216
+ return;
62217
+ }
62141
62218
  setLine((s2) => s2.slice(0, -1));
62142
62219
  return;
62143
62220
  }
62144
62221
  if (key.upArrow || key.downArrow || key.leftArrow || key.rightArrow || key.tab) {
62222
+ imeBufferRef.current?.flush();
62145
62223
  return;
62146
62224
  }
62147
62225
  const newlineIdx = char.search(/[\r\n]/);
@@ -62149,6 +62227,7 @@ var App2 = ({ onReady }) => {
62149
62227
  if (hasNewline) {
62150
62228
  const before = newlineIdx === -1 ? char : char.slice(0, newlineIdx);
62151
62229
  const after = newlineIdx === -1 ? "" : char.slice(newlineIdx + 1).replace(/^[\r\n]/, "");
62230
+ imeBufferRef.current?.flush();
62152
62231
  const submitted = line + before;
62153
62232
  setLine(after);
62154
62233
  print(prompt2 + submitted);
@@ -62161,6 +62240,11 @@ var App2 = ({ onReady }) => {
62161
62240
  }
62162
62241
  return;
62163
62242
  }
62243
+ if (isImeLikeInput(char)) {
62244
+ imeBufferRef.current?.add(char);
62245
+ return;
62246
+ }
62247
+ imeBufferRef.current?.flush();
62164
62248
  setLine((s2) => s2 + char);
62165
62249
  });
62166
62250
  import_react34.default.useEffect(() => {
@@ -62236,7 +62320,7 @@ var InkReadlineAdapter = class extends EventEmitter3 {
62236
62320
  };
62237
62321
 
62238
62322
  // src/commands/chat.ts
62239
- var CLI_VERSION = "0.5.35";
62323
+ var CLI_VERSION = "0.5.37";
62240
62324
  var MODEL_LABELS = {
62241
62325
  turbo: "Nexrall Turbo",
62242
62326
  pro: "Nexrall Pro",
@@ -63651,7 +63735,7 @@ function pluginListCommand() {
63651
63735
 
63652
63736
  // src/index.ts
63653
63737
  var program2 = new Command();
63654
- program2.name("nex").description("Nexrall Code \u2014 AI coding assistant (powered by Nexrall)").version("0.5.35");
63738
+ program2.name("nex").description("Nexrall Code \u2014 AI coding assistant (powered by Nexrall)").version("0.5.37");
63655
63739
  program2.command("auth").description("Login to your Nexrall account").action(authCommand);
63656
63740
  program2.command("logout").description("Log out of your Nexrall account").action(logoutCommand);
63657
63741
  program2.command("update").description("Update nex to the latest version").option("-c, --check", "Check for updates without installing").option("-y, --yes", "Skip confirmation prompt").action(async (opts) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexrall-code",
3
- "version": "0.5.35",
3
+ "version": "0.5.37",
4
4
  "description": "Nexrall Code — AI coding assistant for your terminal (headless agent for scripts, CI and automation)",
5
5
  "keywords": [
6
6
  "ai",