cli-atom 0.2.9 → 0.2.10
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/atom.js +29 -11
- package/docs/README_CONTENT.md +109 -0
- package/package.json +1 -1
package/atom.js
CHANGED
|
@@ -356,6 +356,7 @@ const SLASH_COMMANDS = [
|
|
|
356
356
|
{ name: "exit", desc: "Exit the CLI" },
|
|
357
357
|
];
|
|
358
358
|
|
|
359
|
+
// ─── INTERACTIVE PROMPT (FIXED & ROBUST) ─────────────────────────────────────
|
|
359
360
|
// ─── INTERACTIVE PROMPT (FIXED & ROBUST) ─────────────────────────────────────
|
|
360
361
|
function askPrompt() {
|
|
361
362
|
const sessionStats = `${t.ok}${filesCreated}${t.reset} created ${t.warn}${filesEdited}${t.reset} edited`;
|
|
@@ -370,9 +371,10 @@ function askPrompt() {
|
|
|
370
371
|
let menuIndex = 0;
|
|
371
372
|
let menuItems = [];
|
|
372
373
|
let lastMenuLines = 0;
|
|
374
|
+
let lastVisibleLen = 0;
|
|
373
375
|
|
|
374
376
|
function clearPromptAndMenu() {
|
|
375
|
-
|
|
377
|
+
// 1. Effacer le menu s'il existe
|
|
376
378
|
if (lastMenuLines > 0) {
|
|
377
379
|
for (let i = 0; i < lastMenuLines; i++) {
|
|
378
380
|
process.stdout.write("\x1b[1B\x1b[2K"); // Descend et efface
|
|
@@ -382,6 +384,13 @@ function askPrompt() {
|
|
|
382
384
|
}
|
|
383
385
|
lastMenuLines = 0;
|
|
384
386
|
}
|
|
387
|
+
|
|
388
|
+
// 2. Effacer le prompt (gère le retour à la ligne automatique)
|
|
389
|
+
const linesToClear = Math.max(0, Math.floor((lastVisibleLen - 1) / cols()));
|
|
390
|
+
process.stdout.write("\x1b[2K\r"); // Efface la ligne actuelle
|
|
391
|
+
for (let i = 0; i < linesToClear; i++) {
|
|
392
|
+
process.stdout.write("\x1b[1A\x1b[2K\r"); // Monte d'une ligne et efface
|
|
393
|
+
}
|
|
385
394
|
}
|
|
386
395
|
|
|
387
396
|
function drawPrompt() {
|
|
@@ -389,13 +398,20 @@ function askPrompt() {
|
|
|
389
398
|
|
|
390
399
|
const prefix = ` ${t.violet}❯${t.reset} `;
|
|
391
400
|
const visiblePrefixLen = 4;
|
|
401
|
+
let baseText = "";
|
|
402
|
+
let currentVisibleLen = 0;
|
|
392
403
|
|
|
393
404
|
if (input.length === 0) {
|
|
394
|
-
|
|
405
|
+
baseText = `${t.muted}Insert your instruction... (type / for commands)${t.reset}`;
|
|
406
|
+
currentVisibleLen = visiblePrefixLen + "Insert your instruction... (type / for commands)".length;
|
|
395
407
|
} else {
|
|
396
|
-
|
|
408
|
+
baseText = `${t.accent}${input}${t.reset}`;
|
|
409
|
+
currentVisibleLen = visiblePrefixLen + input.length;
|
|
397
410
|
}
|
|
398
411
|
|
|
412
|
+
process.stdout.write(prefix + baseText);
|
|
413
|
+
lastVisibleLen = currentVisibleLen;
|
|
414
|
+
|
|
399
415
|
let currentMenuLines = 0;
|
|
400
416
|
if (menuActive) {
|
|
401
417
|
const query = input.slice(1).toLowerCase();
|
|
@@ -406,7 +422,7 @@ function askPrompt() {
|
|
|
406
422
|
const item = menuItems[i];
|
|
407
423
|
const isSelected = i === menuIndex;
|
|
408
424
|
const namePad = ("/" + item.name).padEnd(12);
|
|
409
|
-
process.stdout.write(`\n`);
|
|
425
|
+
process.stdout.write(`\r\n`); // S'assure d'aller à la ligne proprement
|
|
410
426
|
if (isSelected) {
|
|
411
427
|
process.stdout.write(` ${t.violet}${t.bold}❯ ${namePad}${t.reset} ${t.accent}${item.desc}${t.reset}`);
|
|
412
428
|
} else {
|
|
@@ -416,13 +432,13 @@ function askPrompt() {
|
|
|
416
432
|
}
|
|
417
433
|
}
|
|
418
434
|
|
|
419
|
-
|
|
420
|
-
process.stdout.write("\x1b[1A");
|
|
421
|
-
}
|
|
422
|
-
|
|
435
|
+
// Repositionner le curseur si le menu est ouvert
|
|
423
436
|
if (currentMenuLines > 0) {
|
|
424
|
-
|
|
425
|
-
|
|
437
|
+
for (let i = 0; i < currentMenuLines; i++) {
|
|
438
|
+
process.stdout.write("\x1b[1A"); // Remonte à la ligne du prompt
|
|
439
|
+
}
|
|
440
|
+
const cursorCol = (currentVisibleLen % cols()) || cols();
|
|
441
|
+
process.stdout.write(`\x1b[${cursorCol}G`); // Définit la colonne exacte
|
|
426
442
|
}
|
|
427
443
|
|
|
428
444
|
lastMenuLines = currentMenuLines;
|
|
@@ -655,7 +671,8 @@ async function handleInput(raw) {
|
|
|
655
671
|
console.log(` ${t.warn}Note: The model returned malformed JSON.${t.reset}\n`);
|
|
656
672
|
conversationHistory.push({ role: "user", content: userPrompt });
|
|
657
673
|
conversationHistory.push({ role: "assistant", content });
|
|
658
|
-
askPrompt()
|
|
674
|
+
// FIX: Removed askPrompt() here to prevent multiple listeners from being registered.
|
|
675
|
+
// The finally block below will handle calling askPrompt().
|
|
659
676
|
return;
|
|
660
677
|
}
|
|
661
678
|
|
|
@@ -798,6 +815,7 @@ async function handleInput(raw) {
|
|
|
798
815
|
} catch (err) {
|
|
799
816
|
stopSpinner(spinner, ` ${t.err}✗ error ${t.muted}${err.message || JSON.stringify(err)}${t.reset}`);
|
|
800
817
|
} finally {
|
|
818
|
+
// This will safely handle restoring the prompt after everything (including early returns)
|
|
801
819
|
askPrompt();
|
|
802
820
|
}
|
|
803
821
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# ⚛️ Atom-AI
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
**Un module Node.js léger et performant pour intégrer des fonctionnalités d'IA dans vos projets.**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/atom-ai)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 📖 À propos
|
|
16
|
+
|
|
17
|
+
**Atom-AI** est un module Node.js conçu pour simplifier l'intégration d'intelligence artificielle dans vos applications. Léger, modulaire et facile à prendre en main, il s'intègre rapidement dans n'importe quel projet JavaScript.
|
|
18
|
+
|
|
19
|
+
## ✨ Fonctionnalités
|
|
20
|
+
|
|
21
|
+
> ⚠️ *Cette section est à compléter avec les fonctionnalités exactes de votre script. Voici une base qu vous pouvez adapter :*
|
|
22
|
+
|
|
23
|
+
- 🚀 **Démarrage rapide** — Prêt à l'emploi en quelques lignes de code
|
|
24
|
+
- 🧠 **Intégration IA** — Connectez-vous facilement à des modèles d'IA
|
|
25
|
+
- 📦 **Léger** — Minimal en dépendances
|
|
26
|
+
- 🔧 **Configurable** — Adaptez le comportement à vos besoins
|
|
27
|
+
- 📝 **Simple** — API claire et intuitive
|
|
28
|
+
|
|
29
|
+
## 📦 Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Via npm
|
|
33
|
+
npm install atom-ai
|
|
34
|
+
|
|
35
|
+
# Via yarn
|
|
36
|
+
yarn add atom-ai
|
|
37
|
+
|
|
38
|
+
# Via pnpm
|
|
39
|
+
pnpm add atom-ai
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 🚀 Utilisation
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
const Atom = require('atom-ai');
|
|
46
|
+
|
|
47
|
+
// Initialisation
|
|
48
|
+
const atom = new Atom({
|
|
49
|
+
// Vos options de configuration
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Utilisation
|
|
53
|
+
atom.run();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## ⚙️ Configuration
|
|
57
|
+
|
|
58
|
+
| Option | Type | Description | Défaut |
|
|
59
|
+
|--------|------|-------------|--------|
|
|
60
|
+
| `option1` | `string` | Description de l'option | `"valeur"` |
|
|
61
|
+
|
|
62
|
+
> 📝 *Complétez ce tableau avec les vraies options de configuration.*
|
|
63
|
+
|
|
64
|
+
## 📁 Structure du projet
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
Atom-Ai/
|
|
68
|
+
├── atom.js # Point d'entrée principal du module
|
|
69
|
+
├── package.json # Métadonnées et dépendances
|
|
70
|
+
├── .npmignore # Fichiers exclus du package npm
|
|
71
|
+
├── .gitignore # Fichiers exclus de Git
|
|
72
|
+
└── README.md # Ce fichier
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 🛠️ Développement
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Cloner le dépôt
|
|
79
|
+
git clone https://github.com/Redwxll-atm/Atom-Ai.git
|
|
80
|
+
cd Atom-Ai
|
|
81
|
+
|
|
82
|
+
# Installer les dépendances
|
|
83
|
+
npm install
|
|
84
|
+
|
|
85
|
+
# Lancer le module
|
|
86
|
+
node atom.js
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 🤝 Contribuer
|
|
90
|
+
|
|
91
|
+
Les contributions sont les bienvenues ! Voici comment participer :
|
|
92
|
+
|
|
93
|
+
1. **Fork** le projet
|
|
94
|
+
2. Créez une branche fonctionnelle (`git checkout -b feature/ma-fonctionnalite`)
|
|
95
|
+
3. **Commit** vos changements (`git commit -m 'Ajout de ma fonctionnalité'`)
|
|
96
|
+
4. **Push** vers la branche (`git push origin feature/ma-fonctionnalite`)
|
|
97
|
+
5. Ouvrez une **Pull Request**
|
|
98
|
+
|
|
99
|
+
## 📄 Licence
|
|
100
|
+
|
|
101
|
+
Ce projet est sous licence **MIT**. Voir le fichier [LICENSE](LICENSE) pour plus de détails.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
<div align="center">
|
|
106
|
+
|
|
107
|
+
Développé avec ❤️ par **[Redwxll](https://github.com/Redwxll-atm)**
|
|
108
|
+
|
|
109
|
+
</div>
|