nexrall-code 0.5.37 → 0.5.39

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 +33 -100
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -62092,74 +62092,31 @@ 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
-
62158
62095
  // src/ui/inkTerminal.tsx
62159
62096
  function footerText(info) {
62160
62097
  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";
62161
62098
  return `${modeLabel} \xB7 /help for shortcuts \xB7 /agents for agents`;
62162
62099
  }
62100
+ var IntlWithSegmenter = Intl;
62101
+ var graphemeSegmenter = typeof IntlWithSegmenter.Segmenter === "function" ? new IntlWithSegmenter.Segmenter(void 0, { granularity: "grapheme" }) : null;
62102
+ function dropLastGrapheme(text) {
62103
+ if (!text)
62104
+ return "";
62105
+ if (graphemeSegmenter) {
62106
+ let lastStart = 0;
62107
+ for (const { index } of graphemeSegmenter.segment(text))
62108
+ lastStart = index;
62109
+ return text.slice(0, lastStart);
62110
+ }
62111
+ let end = text.length - 1;
62112
+ while (end > 0 && /[\u0300-\u036F\u1AB0-\u1AFF\u20D0-\u20F0]/.test(text[end]))
62113
+ end--;
62114
+ const prev = text.charCodeAt(end - 1);
62115
+ const curr = text.charCodeAt(end);
62116
+ if (end > 0 && prev >= 55296 && prev <= 56319 && curr >= 56320 && curr <= 57343)
62117
+ end--;
62118
+ return text.slice(0, end);
62119
+ }
62163
62120
  var handle = null;
62164
62121
  var inkInstance = null;
62165
62122
  var idCounter = 0;
@@ -62168,9 +62125,15 @@ var App2 = ({ onReady }) => {
62168
62125
  const [items, setItems] = (0, import_react34.useState)([]);
62169
62126
  const [footer, setFooterState] = (0, import_react34.useState)({ mode: "auto", autoApprove: false });
62170
62127
  const [inputEnabled, setInputEnabledState] = (0, import_react34.useState)(true);
62171
- const [line, setLine] = (0, import_react34.useState)("");
62128
+ const [line, setLineState] = (0, import_react34.useState)("");
62172
62129
  const [prompt2, setPrompt] = (0, import_react34.useState)(DEFAULT_PROMPT);
62173
62130
  const { exit } = use_app_default();
62131
+ const lineRef = (0, import_react34.useRef)("");
62132
+ const setLine = (0, import_react34.useCallback)((next) => {
62133
+ const value = typeof next === "function" ? next(lineRef.current) : next;
62134
+ lineRef.current = value;
62135
+ setLineState(value);
62136
+ }, []);
62174
62137
  const askResolverRef = (0, import_react34.useRef)(null);
62175
62138
  const onLineRef = (0, import_react34.useRef)(null);
62176
62139
  const [live, setLiveState] = (0, import_react34.useState)("");
@@ -62193,16 +62156,6 @@ var App2 = ({ onReady }) => {
62193
62156
  const onLine = (0, import_react34.useCallback)((cb) => {
62194
62157
  onLineRef.current = cb;
62195
62158
  }, []);
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
- }, []);
62206
62159
  use_input_default((char, key) => {
62207
62160
  if (!inputEnabled)
62208
62161
  return;
@@ -62211,15 +62164,10 @@ var App2 = ({ onReady }) => {
62211
62164
  return;
62212
62165
  }
62213
62166
  if (key.backspace || key.delete) {
62214
- if (imeBufferRef.current?.hasContent()) {
62215
- imeBufferRef.current.backspace();
62216
- return;
62217
- }
62218
- setLine((s2) => s2.slice(0, -1));
62167
+ setLine((s2) => dropLastGrapheme(s2));
62219
62168
  return;
62220
62169
  }
62221
62170
  if (key.upArrow || key.downArrow || key.leftArrow || key.rightArrow || key.tab) {
62222
- imeBufferRef.current?.flush();
62223
62171
  return;
62224
62172
  }
62225
62173
  const newlineIdx = char.search(/[\r\n]/);
@@ -62227,8 +62175,7 @@ var App2 = ({ onReady }) => {
62227
62175
  if (hasNewline) {
62228
62176
  const before = newlineIdx === -1 ? char : char.slice(0, newlineIdx);
62229
62177
  const after = newlineIdx === -1 ? "" : char.slice(newlineIdx + 1).replace(/^[\r\n]/, "");
62230
- imeBufferRef.current?.flush();
62231
- const submitted = line + before;
62178
+ const submitted = lineRef.current + before;
62232
62179
  setLine(after);
62233
62180
  print(prompt2 + submitted);
62234
62181
  const askResolve = askResolverRef.current;
@@ -62240,11 +62187,6 @@ var App2 = ({ onReady }) => {
62240
62187
  }
62241
62188
  return;
62242
62189
  }
62243
- if (isImeLikeInput(char)) {
62244
- imeBufferRef.current?.add(char);
62245
- return;
62246
- }
62247
- imeBufferRef.current?.flush();
62248
62190
  setLine((s2) => s2 + char);
62249
62191
  });
62250
62192
  import_react34.default.useEffect(() => {
@@ -62320,7 +62262,7 @@ var InkReadlineAdapter = class extends EventEmitter3 {
62320
62262
  };
62321
62263
 
62322
62264
  // src/commands/chat.ts
62323
- var CLI_VERSION = "0.5.37";
62265
+ var CLI_VERSION = "0.5.39";
62324
62266
  var MODEL_LABELS = {
62325
62267
  turbo: "Nexrall Turbo",
62326
62268
  pro: "Nexrall Pro",
@@ -63141,11 +63083,7 @@ ${summaryText}` }] },
63141
63083
  case "/init": {
63142
63084
  const nexrallMdPath = path3.join(workDir, "nexrall.md");
63143
63085
  if (fs7.existsSync(nexrallMdPath)) {
63144
- const rl2 = readline3.createInterface({ input: process.stdin, output: process.stdout });
63145
- const answer = await new Promise((resolve3) => rl2.question(source_default.yellow(" nexrall.md already exists. Overwrite? [y/n] "), (a) => {
63146
- rl2.close();
63147
- resolve3(a.trim());
63148
- }));
63086
+ const answer = await new Promise((resolve3) => rl.question(source_default.yellow(" nexrall.md already exists. Overwrite? [y/n] "), (a) => resolve3(a.trim())));
63149
63087
  if (answer !== "y" && answer !== "yes") {
63150
63088
  console.log(source_default.dim(" Cancelled."));
63151
63089
  rl.prompt();
@@ -63202,13 +63140,8 @@ ${dirList}`;
63202
63140
  const wantsClear = memArgs.includes("clear");
63203
63141
  const memScope = wantsGlobalOnly ? "global" : "project";
63204
63142
  if (wantsClear) {
63205
- rl.pause();
63206
- const rl2 = readline3.createInterface({ input: process.stdin, output: process.stdout });
63207
63143
  const label = memScope === "global" ? "GLOBAL" : "this PROJECT's";
63208
- const answer = await new Promise((resolve3) => rl2.question(source_default.yellow(` Clear ${label} memory? This cannot be undone. [y/n] `), (a) => {
63209
- rl2.close();
63210
- resolve3(a.trim());
63211
- }));
63144
+ const answer = await new Promise((resolve3) => rl.question(source_default.yellow(` Clear ${label} memory? This cannot be undone. [y/n] `), (a) => resolve3(a.trim())));
63212
63145
  if (answer === "y" || answer === "yes") {
63213
63146
  (0, import_code_core3.clearMemory)(memScope, workDir);
63214
63147
  console.log(source_default.green(` ${memScope === "global" ? "Global" : "Project"} memory cleared.`));
@@ -63735,7 +63668,7 @@ function pluginListCommand() {
63735
63668
 
63736
63669
  // src/index.ts
63737
63670
  var program2 = new Command();
63738
- program2.name("nex").description("Nexrall Code \u2014 AI coding assistant (powered by Nexrall)").version("0.5.37");
63671
+ program2.name("nex").description("Nexrall Code \u2014 AI coding assistant (powered by Nexrall)").version("0.5.39");
63739
63672
  program2.command("auth").description("Login to your Nexrall account").action(authCommand);
63740
63673
  program2.command("logout").description("Log out of your Nexrall account").action(logoutCommand);
63741
63674
  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.37",
3
+ "version": "0.5.39",
4
4
  "description": "Nexrall Code — AI coding assistant for your terminal (headless agent for scripts, CI and automation)",
5
5
  "keywords": [
6
6
  "ai",