@rnbsolucoes/axion-code 0.1.51 → 0.1.53

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/README.md CHANGED
@@ -112,6 +112,21 @@ current platform into the local Axion Code bin directory and then executes it. I
112
112
  a source clone only, if no packaged binary exists, the wrapper can build from Go
113
113
  as a development fallback.
114
114
 
115
+ ### Terminal setup (multi-line composer)
116
+
117
+ In the chat composer, **Enter sends** and **Ctrl+J inserts a newline**. Terminals
118
+ do not report Shift+Enter or Ctrl+Enter as distinct keys to the app on Windows,
119
+ so to use those keys for a line break, run once after install:
120
+
121
+ ```powershell
122
+ axion terminal-setup
123
+ ```
124
+
125
+ It maps **Shift+Enter** and **Ctrl+Enter** to send a newline in Windows Terminal
126
+ (idempotent, writes a `settings.json.axion-bak` backup). Reopen the terminal tab
127
+ if the change does not take effect immediately. On other terminals, bind
128
+ Shift+Enter / Ctrl+Enter to send a newline (`\n`) manually.
129
+
115
130
  To classify the currently executed binary for support or security review, run:
116
131
 
117
132
  ```powershell
package/npm/bin/axion.mjs CHANGED
@@ -312,9 +312,11 @@ async function updateCommandHandler(args) {
312
312
  }
313
313
  const source = info.source === packageJSON.name ? packageJSON.name : updateSource;
314
314
  console.log(`Updating Axion Code from ${source}...`);
315
+ // shell:true so Windows resolves npm.cmd (spawning bare "npm" with shell:false
316
+ // fails with ENOENT there). Args are fixed constants, so no injection risk.
315
317
  const result = spawnSync("npm", ["install", "-g", source], {
316
318
  stdio: "inherit",
317
- shell: false
319
+ shell: true
318
320
  });
319
321
  if (result.error) {
320
322
  console.error(result.error.message);
@@ -326,11 +328,81 @@ async function updateCommandHandler(args) {
326
328
  console.log("Axion Code update completed. Run axion again.");
327
329
  }
328
330
 
331
+ function terminalSetupHandler() {
332
+ // Map Shift+Enter and Ctrl+Enter to send a literal newline (LF). Axion's
333
+ // composer inserts a line break on LF, while plain Enter (CR) still sends.
334
+ // This is needed because terminals do not report Shift+Enter/Ctrl+Enter as
335
+ // distinct keys to the app on Windows.
336
+ if (!isWindows) {
337
+ console.log("axion terminal-setup currently automates Windows Terminal.");
338
+ console.log("On other terminals, bind Shift+Enter (and/or Ctrl+Enter) to send a newline (\\n).");
339
+ return;
340
+ }
341
+ const localAppData = process.env.LOCALAPPDATA || join(process.env.USERPROFILE || root, "AppData", "Local");
342
+ const candidates = [
343
+ join(localAppData, "Packages", "Microsoft.WindowsTerminal_8wekyb3d8bbwe", "LocalState", "settings.json"),
344
+ join(localAppData, "Packages", "Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe", "LocalState", "settings.json"),
345
+ join(localAppData, "Microsoft", "Windows Terminal", "settings.json")
346
+ ];
347
+ const settingsPath = candidates.find((p) => existsSync(p));
348
+ if (!settingsPath) {
349
+ console.log("Windows Terminal settings.json not found.");
350
+ console.log("If you use another terminal, bind Shift+Enter / Ctrl+Enter to send a newline (\\n).");
351
+ return;
352
+ }
353
+ let settings;
354
+ try {
355
+ settings = JSON.parse(readFileSync(settingsPath, "utf8"));
356
+ } catch (err) {
357
+ console.error(`Could not parse ${settingsPath}: ${err.message}`);
358
+ process.exit(1);
359
+ }
360
+ if (!Array.isArray(settings.keybindings)) settings.keybindings = [];
361
+ const wanted = ["shift+enter", "ctrl+enter"];
362
+ // Windows Terminal may normalize an inline {command,keys} binding into an
363
+ // id-based one ({id,keys}) plus an entry in `actions`, so resolve both forms.
364
+ const effectiveCommand = (k) => {
365
+ if (!k) return null;
366
+ if (k.command) return k.command;
367
+ if (k.id) {
368
+ const a = (settings.actions || []).find((x) => x && x.id === k.id);
369
+ if (a && a.command) return a.command;
370
+ }
371
+ return null;
372
+ };
373
+ const isOurs = (k, keys) => {
374
+ if (!k || k.keys !== keys) return false;
375
+ const c = effectiveCommand(k);
376
+ return c && c.action === "sendInput" && c.input === "\n";
377
+ };
378
+ if (wanted.every((keys) => settings.keybindings.some((k) => isOurs(k, keys)))) {
379
+ console.log("Windows Terminal is already set up: Shift+Enter and Ctrl+Enter insert a newline.");
380
+ return;
381
+ }
382
+ settings.keybindings = settings.keybindings.filter((k) => !(k && wanted.includes(k.keys)));
383
+ for (const keys of wanted) {
384
+ settings.keybindings.push({ command: { action: "sendInput", input: "\n" }, keys });
385
+ }
386
+ const backup = `${settingsPath}.axion-bak`;
387
+ try {
388
+ copyFileSync(settingsPath, backup);
389
+ } catch {}
390
+ writeFileSync(settingsPath, JSON.stringify(settings, null, 4));
391
+ console.log("Windows Terminal configured: Shift+Enter and Ctrl+Enter now insert a newline in Axion (Enter still sends).");
392
+ console.log(`Settings: ${settingsPath}`);
393
+ console.log(`Backup: ${backup}`);
394
+ console.log("Reopen the terminal tab if the change does not take effect immediately.");
395
+ }
396
+
329
397
  const args = process.argv.slice(2);
330
398
  if (args[0] === "update") {
331
399
  await updateCommandHandler(args.slice(1));
332
400
  process.exit(0);
333
401
  }
402
+ if (args[0] === "terminal-setup") {
403
+ terminalSetupHandler();
404
+ process.exit(0);
405
+ }
334
406
 
335
407
  const updateInfo = await readUpdateInfo();
336
408
  ensureBinary();
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnbsolucoes/axion-code",
3
- "version": "0.1.51",
3
+ "version": "0.1.53",
4
4
  "description": "Axion Code CLI harness for the Axion ecosystem.",
5
5
  "type": "module",
6
6
  "repository": {