cli-atom 0.2.9 → 0.2.11

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/atom.js +38 -17
  2. package/package.json +1 -1
package/atom.js CHANGED
@@ -44,16 +44,19 @@ const MAX_FILE_SIZE = 15_000;
44
44
  const MAX_FILES = 15;
45
45
  const MAX_CONTEXT_CHARS = 20_000;
46
46
 
47
- let MODEL = "z-ai/glm-5-turbo";
48
- let MODEL_LABEL = "glm-5-turbo";
47
+ let MODEL = "z-ai/glm-5.2";
48
+ let MODEL_LABEL = "glm-5.2";
49
49
  const VERSION = _require("./package.json").version;
50
50
 
51
51
  const MODELS = [
52
+ // Modèle interne Puter (Gratuit)
52
53
  { id: "z-ai/glm-5-turbo", label: "glm-5-turbo" },
53
- { id: "openai/gpt-4o", label: "gpt-4o" },
54
- { id: "openai/gpt-4-turbo", label: "gpt-4-turbo" },
55
- { id: "meta-llama/llama-3-70b-instruct", label: "llama-3-70b" },
56
- { id: "mistral-large", label: "mistral-large" }
54
+
55
+ // Modèles OpenAI (Très stables via Puter)
56
+ { id: "gpt-4o", label: "gpt-4o" },
57
+ { id: "gpt-4o-mini", label: "gpt-4o-mini" },
58
+ { id: "gpt-4-turbo", label: "gpt-4-turbo" },
59
+ { id: "gpt-3.5-turbo", label: "gpt-3.5-turbo" }
57
60
  ];
58
61
 
59
62
  // ─── CONFIG MANAGEMENT ───────────────────────────────────────────────────────
@@ -356,6 +359,7 @@ const SLASH_COMMANDS = [
356
359
  { name: "exit", desc: "Exit the CLI" },
357
360
  ];
358
361
 
362
+ // ─── INTERACTIVE PROMPT (FIXED & ROBUST) ─────────────────────────────────────
359
363
  // ─── INTERACTIVE PROMPT (FIXED & ROBUST) ─────────────────────────────────────
360
364
  function askPrompt() {
361
365
  const sessionStats = `${t.ok}${filesCreated}${t.reset} created ${t.warn}${filesEdited}${t.reset} edited`;
@@ -370,9 +374,10 @@ function askPrompt() {
370
374
  let menuIndex = 0;
371
375
  let menuItems = [];
372
376
  let lastMenuLines = 0;
377
+ let lastVisibleLen = 0;
373
378
 
374
379
  function clearPromptAndMenu() {
375
- process.stdout.write("\x1b[2K\r"); // Efface la ligne de prompt
380
+ // 1. Effacer le menu s'il existe
376
381
  if (lastMenuLines > 0) {
377
382
  for (let i = 0; i < lastMenuLines; i++) {
378
383
  process.stdout.write("\x1b[1B\x1b[2K"); // Descend et efface
@@ -382,6 +387,13 @@ function askPrompt() {
382
387
  }
383
388
  lastMenuLines = 0;
384
389
  }
390
+
391
+ // 2. Effacer le prompt (gère le retour à la ligne automatique)
392
+ const linesToClear = Math.max(0, Math.floor((lastVisibleLen - 1) / cols()));
393
+ process.stdout.write("\x1b[2K\r"); // Efface la ligne actuelle
394
+ for (let i = 0; i < linesToClear; i++) {
395
+ process.stdout.write("\x1b[1A\x1b[2K\r"); // Monte d'une ligne et efface
396
+ }
385
397
  }
386
398
 
387
399
  function drawPrompt() {
@@ -389,13 +401,20 @@ function askPrompt() {
389
401
 
390
402
  const prefix = ` ${t.violet}❯${t.reset} `;
391
403
  const visiblePrefixLen = 4;
404
+ let baseText = "";
405
+ let currentVisibleLen = 0;
392
406
 
393
407
  if (input.length === 0) {
394
- process.stdout.write(`${prefix}${t.muted}Insert your instruction... (type / for commands)${t.reset}`);
408
+ baseText = `${t.muted}Insert your instruction... (type / for commands)${t.reset}`;
409
+ currentVisibleLen = visiblePrefixLen + "Insert your instruction... (type / for commands)".length;
395
410
  } else {
396
- process.stdout.write(`${prefix}${t.accent}${input}${t.reset}`);
411
+ baseText = `${t.accent}${input}${t.reset}`;
412
+ currentVisibleLen = visiblePrefixLen + input.length;
397
413
  }
398
414
 
415
+ process.stdout.write(prefix + baseText);
416
+ lastVisibleLen = currentVisibleLen;
417
+
399
418
  let currentMenuLines = 0;
400
419
  if (menuActive) {
401
420
  const query = input.slice(1).toLowerCase();
@@ -406,7 +425,7 @@ function askPrompt() {
406
425
  const item = menuItems[i];
407
426
  const isSelected = i === menuIndex;
408
427
  const namePad = ("/" + item.name).padEnd(12);
409
- process.stdout.write(`\n`);
428
+ process.stdout.write(`\r\n`); // S'assure d'aller à la ligne proprement
410
429
  if (isSelected) {
411
430
  process.stdout.write(` ${t.violet}${t.bold}❯ ${namePad}${t.reset} ${t.accent}${item.desc}${t.reset}`);
412
431
  } else {
@@ -416,13 +435,13 @@ function askPrompt() {
416
435
  }
417
436
  }
418
437
 
419
- for (let i = 0; i < currentMenuLines; i++) {
420
- process.stdout.write("\x1b[1A");
421
- }
422
-
438
+ // Repositionner le curseur si le menu est ouvert
423
439
  if (currentMenuLines > 0) {
424
- const col = visiblePrefixLen + input.length + 1;
425
- process.stdout.write(`\x1b[${col}G`);
440
+ for (let i = 0; i < currentMenuLines; i++) {
441
+ process.stdout.write("\x1b[1A"); // Remonte à la ligne du prompt
442
+ }
443
+ const cursorCol = (currentVisibleLen % cols()) || cols();
444
+ process.stdout.write(`\x1b[${cursorCol}G`); // Définit la colonne exacte
426
445
  }
427
446
 
428
447
  lastMenuLines = currentMenuLines;
@@ -655,7 +674,8 @@ async function handleInput(raw) {
655
674
  console.log(` ${t.warn}Note: The model returned malformed JSON.${t.reset}\n`);
656
675
  conversationHistory.push({ role: "user", content: userPrompt });
657
676
  conversationHistory.push({ role: "assistant", content });
658
- askPrompt();
677
+ // FIX: Removed askPrompt() here to prevent multiple listeners from being registered.
678
+ // The finally block below will handle calling askPrompt().
659
679
  return;
660
680
  }
661
681
 
@@ -798,6 +818,7 @@ async function handleInput(raw) {
798
818
  } catch (err) {
799
819
  stopSpinner(spinner, ` ${t.err}✗ error ${t.muted}${err.message || JSON.stringify(err)}${t.reset}`);
800
820
  } finally {
821
+ // This will safely handle restoring the prompt after everything (including early returns)
801
822
  askPrompt();
802
823
  }
803
824
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-atom",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "ATOM - Coding Agent",
5
5
  "license": "ISC",
6
6
  "author": "Redwxll",