Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
index.js
CHANGED
|
@@ -10,16 +10,31 @@ import { execSync } from 'child_process';
|
|
| 10 |
import { marked } from 'marked';
|
| 11 |
import TerminalRenderer from 'marked-terminal';
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
// Configurer le rendu Markdown pour le terminal (styles chalk)
|
| 14 |
marked.setOptions({
|
| 15 |
renderer: new TerminalRenderer({
|
| 16 |
-
code:
|
| 17 |
-
blockquote:
|
| 18 |
-
html:
|
| 19 |
-
heading:
|
| 20 |
-
firstHeading:
|
| 21 |
-
listitem:
|
| 22 |
-
table:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
tab: 2
|
| 24 |
})
|
| 25 |
});
|
|
@@ -58,16 +73,15 @@ function addLog(level, message) {
|
|
| 58 |
logs.push(logItem);
|
| 59 |
}
|
| 60 |
|
| 61 |
-
|
| 62 |
-
const BANNER = chalk.cyan.bold(`
|
| 63 |
_____ _---------------+
|
| 64 |
/ ____| | | ____ _ |
|
| 65 |
| | _ _ _ __ | |__| _ \\| | | CYPHER CODER CLI
|
| 66 |
| | | | | | '_ \\ | __ |_) | | | L'IA experte en développement local
|
| 67 |
| |___| |_| | |_) || | | __/| |___ | Créé par ${AUTHOR}
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
`);
|
| 72 |
|
| 73 |
// -----------------------------------------------------
|
|
@@ -261,7 +275,7 @@ async function handleToolExecution(name, args) {
|
|
| 261 |
case 'write_file':
|
| 262 |
try {
|
| 263 |
const targetPath = path.resolve(args.path);
|
| 264 |
-
console.log(
|
| 265 |
const { confirmWrite } = await inquirer.prompt([
|
| 266 |
{
|
| 267 |
type: 'confirm',
|
|
@@ -290,7 +304,7 @@ async function handleToolExecution(name, args) {
|
|
| 290 |
case 'patch_file':
|
| 291 |
try {
|
| 292 |
const targetPath = path.resolve(args.path);
|
| 293 |
-
console.log(
|
| 294 |
|
| 295 |
console.log(chalk.dim("--- BLOC À RECHERCHER ---"));
|
| 296 |
console.log(chalk.red(args.search));
|
|
@@ -412,7 +426,7 @@ async function handleToolExecution(name, args) {
|
|
| 412 |
|
| 413 |
case 'run_command':
|
| 414 |
try {
|
| 415 |
-
console.log(
|
| 416 |
console.log(chalk.bgBlack.white(` $ ${args.command} `));
|
| 417 |
|
| 418 |
const { confirmCommand } = await inquirer.prompt([
|
|
@@ -442,6 +456,36 @@ async function handleToolExecution(name, args) {
|
|
| 442 |
}
|
| 443 |
}
|
| 444 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 445 |
// -----------------------------------------------------
|
| 446 |
// Prompt Système Dynamique & Intelligent
|
| 447 |
// -----------------------------------------------------
|
|
@@ -734,7 +778,7 @@ async function runAgentTurn() {
|
|
| 734 |
if (replyMessage.content) {
|
| 735 |
lastAssistantResponse = replyMessage.content;
|
| 736 |
addLog("INFO", "Réponse de l'assistant enregistrée.");
|
| 737 |
-
console.log(
|
| 738 |
// Rendre le Markdown de l'IA avec formatage ANSI coloré
|
| 739 |
console.log(marked(replyMessage.content));
|
| 740 |
}
|
|
@@ -745,8 +789,7 @@ async function runAgentTurn() {
|
|
| 745 |
const name = tc.function.name;
|
| 746 |
const args = JSON.parse(tc.function.arguments);
|
| 747 |
|
| 748 |
-
|
| 749 |
-
const result = await handleToolExecution(name, args);
|
| 750 |
|
| 751 |
// Ajouter le résultat de l'outil à la conversation
|
| 752 |
chatMessages.push({
|
|
@@ -799,9 +842,9 @@ async function handleSlashCommand(text) {
|
|
| 799 |
switch (commandName.toLowerCase()) {
|
| 800 |
// --- 1. Contrôle de session
|
| 801 |
case '/help':
|
| 802 |
-
console.log(
|
| 803 |
|
| 804 |
-
console.log(
|
| 805 |
console.log(" /help - Affiche ce menu d'aide");
|
| 806 |
console.log(" /exit, /quit - Quitte proprement l'agent");
|
| 807 |
console.log(" /clear - Efface l'écran");
|
|
@@ -811,7 +854,7 @@ async function handleSlashCommand(text) {
|
|
| 811 |
console.log(" /about - Infos sur le projet");
|
| 812 |
console.log(" /status - Affiche le statut complet");
|
| 813 |
|
| 814 |
-
console.log(
|
| 815 |
console.log(" /context - Affiche les fichiers chargés en contexte");
|
| 816 |
console.log(" /context clear - Efface le contexte de fichiers");
|
| 817 |
console.log(" /context save <nom> - Sauvegarde la session actuelle");
|
|
@@ -821,7 +864,7 @@ async function handleSlashCommand(text) {
|
|
| 821 |
console.log(" /memory clear - Efface les messages d'historique");
|
| 822 |
console.log(" /tokens - Affiche les statistiques de tokens");
|
| 823 |
|
| 824 |
-
console.log(
|
| 825 |
console.log(" /history - Affiche tout l'historique");
|
| 826 |
console.log(" /history clear - Efface l'historique enregistré");
|
| 827 |
console.log(" /history save <fichier> - Exporte l'historique dans un fichier");
|
|
@@ -831,7 +874,7 @@ async function handleSlashCommand(text) {
|
|
| 831 |
console.log(" /redo - Relance la dernière requête");
|
| 832 |
console.log(" /undo - Annule la dernière interaction");
|
| 833 |
|
| 834 |
-
console.log(
|
| 835 |
console.log(" /model - Affiche le modèle utilisé");
|
| 836 |
console.log(" /model list - Liste les modèles supportés");
|
| 837 |
console.log(" /model set <nom> - Change de modèle");
|
|
@@ -844,7 +887,7 @@ async function handleSlashCommand(text) {
|
|
| 844 |
console.log(" /system reset - Réinitialise le prompt système");
|
| 845 |
console.log(" /stream <on|off> - Active/désactive le streaming");
|
| 846 |
|
| 847 |
-
console.log(
|
| 848 |
console.log(" /file load <chemin> - Charge le fichier dans le contexte");
|
| 849 |
console.log(" /file read <chemin> - Lit et affiche un fichier");
|
| 850 |
console.log(" /file write <chemin> - Écrit la dernière réponse dans un fichier");
|
|
@@ -855,7 +898,7 @@ async function handleSlashCommand(text) {
|
|
| 855 |
console.log(" /upload <chemin> - Simule l'envoi d'un fichier");
|
| 856 |
console.log(" /download <nom> - Télécharge un fichier");
|
| 857 |
|
| 858 |
-
console.log(
|
| 859 |
console.log(" /run - Exécute le dernier bloc de code");
|
| 860 |
console.log(" /run <lang> <code> - Exécute le code fourni");
|
| 861 |
console.log(" /exec <commande> - Lance une commande système");
|
|
@@ -866,7 +909,7 @@ async function handleSlashCommand(text) {
|
|
| 866 |
console.log(" /output - Affiche la dernière sortie");
|
| 867 |
console.log(" /output clear - Efface la dernière sortie");
|
| 868 |
|
| 869 |
-
console.log(
|
| 870 |
console.log(" /tools - Liste les outils activés");
|
| 871 |
console.log(" /tool info <nom> - Affiche la description d'un outil");
|
| 872 |
console.log(" /tool enable/disable <n> - Active/désactive un outil");
|
|
@@ -874,7 +917,7 @@ async function handleSlashCommand(text) {
|
|
| 874 |
console.log(" /web search <requête> - Recherche en ligne");
|
| 875 |
console.log(" /web fetch <url> - Récupère le contenu d'une URL");
|
| 876 |
|
| 877 |
-
console.log(
|
| 878 |
console.log(" /theme <dark|light> - Change le thème");
|
| 879 |
console.log(" /theme list - Liste les thèmes");
|
| 880 |
console.log(" /format <md|plain|json> - Format des réponses");
|
|
@@ -884,7 +927,7 @@ async function handleSlashCommand(text) {
|
|
| 884 |
console.log(" /color <on|off> - Colorisation syntaxique");
|
| 885 |
console.log(" /lang <fr|en> - Change la langue");
|
| 886 |
|
| 887 |
-
console.log(
|
| 888 |
console.log(" /config - Affiche la configuration");
|
| 889 |
console.log(" /config set <key> <val> - Modifie la configuration");
|
| 890 |
console.log(" /config reset - Réinitialise la configuration");
|
|
@@ -892,7 +935,7 @@ async function handleSlashCommand(text) {
|
|
| 892 |
console.log(" /env set <VAR> <val> - Définit une variable d'env");
|
| 893 |
console.log(" /api key show/set/clear - Gère les clés d'API");
|
| 894 |
|
| 895 |
-
console.log(
|
| 896 |
console.log(" /debug <on|off> - Active le mode debug");
|
| 897 |
console.log(" /log - Affiche les logs");
|
| 898 |
console.log(" /log clear/save - Efface ou enregistre les logs");
|
|
@@ -902,7 +945,7 @@ async function handleSlashCommand(text) {
|
|
| 902 |
console.log(" /trace - Trace des appels");
|
| 903 |
console.log(" /inspect <var> - Inspecte la configuration interne");
|
| 904 |
|
| 905 |
-
console.log(
|
| 906 |
console.log(" /macro save/run/list/del - Gère les macros");
|
| 907 |
console.log(" /pipe <cmd1> | <cmd2> - Chaîne deux commandes");
|
| 908 |
console.log(" /loop <n> <commande> - Répète une commande");
|
|
@@ -1046,7 +1089,7 @@ async function handleSlashCommand(text) {
|
|
| 1046 |
if (!lastAssistantResponse) {
|
| 1047 |
console.log(chalk.yellow("Aucune réponse précédente disponible."));
|
| 1048 |
} else {
|
| 1049 |
-
console.log(
|
| 1050 |
console.log(marked(lastAssistantResponse));
|
| 1051 |
}
|
| 1052 |
break;
|
|
@@ -1569,11 +1612,12 @@ async function executeLocalCode(lang, code) {
|
|
| 1569 |
}
|
| 1570 |
|
| 1571 |
async function askQuestion() {
|
|
|
|
| 1572 |
const { userInput } = await inquirer.prompt([
|
| 1573 |
{
|
| 1574 |
type: 'input',
|
| 1575 |
name: 'userInput',
|
| 1576 |
-
message:
|
| 1577 |
prefix: ''
|
| 1578 |
}
|
| 1579 |
]);
|
|
@@ -1584,6 +1628,9 @@ async function askQuestion() {
|
|
| 1584 |
return askQuestion();
|
| 1585 |
}
|
| 1586 |
|
|
|
|
|
|
|
|
|
|
| 1587 |
if (text.startsWith('/')) {
|
| 1588 |
const handled = await handleSlashCommand(text);
|
| 1589 |
if (handled) {
|
|
@@ -1601,7 +1648,19 @@ async function askQuestion() {
|
|
| 1601 |
}
|
| 1602 |
|
| 1603 |
async function main() {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1604 |
console.log(BANNER);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1605 |
|
| 1606 |
// Initialiser la session de chat
|
| 1607 |
initChat();
|
|
@@ -1610,7 +1669,9 @@ async function main() {
|
|
| 1610 |
const args = process.argv.slice(2);
|
| 1611 |
if (args.length > 0) {
|
| 1612 |
const initialRequest = args.join(" ");
|
| 1613 |
-
|
|
|
|
|
|
|
| 1614 |
if (initialRequest.startsWith('/')) {
|
| 1615 |
await handleSlashCommand(initialRequest);
|
| 1616 |
} else {
|
|
|
|
| 10 |
import { marked } from 'marked';
|
| 11 |
import TerminalRenderer from 'marked-terminal';
|
| 12 |
|
| 13 |
+
const theme = {
|
| 14 |
+
agent: chalk.hex('#00FFAA'),
|
| 15 |
+
user: chalk.hex('#C792EA'),
|
| 16 |
+
command: chalk.hex('#FFD700'),
|
| 17 |
+
error: chalk.hex('#FF5555'),
|
| 18 |
+
info: chalk.hex('#569CD6'),
|
| 19 |
+
border: chalk.hex('#2A2A2A'),
|
| 20 |
+
text: chalk.hex('#E0E0E0')
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
// Configurer le rendu Markdown pour le terminal (styles chalk)
|
| 24 |
marked.setOptions({
|
| 25 |
renderer: new TerminalRenderer({
|
| 26 |
+
code: theme.command,
|
| 27 |
+
blockquote: theme.agent,
|
| 28 |
+
html: theme.agent,
|
| 29 |
+
heading: theme.info,
|
| 30 |
+
firstHeading: theme.info,
|
| 31 |
+
listitem: theme.agent,
|
| 32 |
+
table: theme.agent,
|
| 33 |
+
strong: theme.agent,
|
| 34 |
+
em: theme.agent,
|
| 35 |
+
link: theme.info,
|
| 36 |
+
href: theme.info,
|
| 37 |
+
unstyled: theme.agent,
|
| 38 |
tab: 2
|
| 39 |
})
|
| 40 |
});
|
|
|
|
| 73 |
logs.push(logItem);
|
| 74 |
}
|
| 75 |
|
| 76 |
+
const BANNER = theme.info(`
|
|
|
|
| 77 |
_____ _---------------+
|
| 78 |
/ ____| | | ____ _ |
|
| 79 |
| | _ _ _ __ | |__| _ \\| | | CYPHER CODER CLI
|
| 80 |
| | | | | | '_ \\ | __ |_) | | | L'IA experte en développement local
|
| 81 |
| |___| |_| | |_) || | | __/| |___ | Créé par ${AUTHOR}
|
| 82 |
+
\\_____\\__, | .__/ |_| |_| |_____|
|
| 83 |
+
__/ | |
|
| 84 |
+
|___/|_| +-----------------------+
|
| 85 |
`);
|
| 86 |
|
| 87 |
// -----------------------------------------------------
|
|
|
|
| 275 |
case 'write_file':
|
| 276 |
try {
|
| 277 |
const targetPath = path.resolve(args.path);
|
| 278 |
+
console.log(theme.info(`\nCypher Coder veut modifier/créer le fichier : ${chalk.cyan(targetPath)}`));
|
| 279 |
const { confirmWrite } = await inquirer.prompt([
|
| 280 |
{
|
| 281 |
type: 'confirm',
|
|
|
|
| 304 |
case 'patch_file':
|
| 305 |
try {
|
| 306 |
const targetPath = path.resolve(args.path);
|
| 307 |
+
console.log(theme.info(`\nCypher Coder veut modifier un bloc de code dans : ${chalk.cyan(targetPath)}`));
|
| 308 |
|
| 309 |
console.log(chalk.dim("--- BLOC À RECHERCHER ---"));
|
| 310 |
console.log(chalk.red(args.search));
|
|
|
|
| 426 |
|
| 427 |
case 'run_command':
|
| 428 |
try {
|
| 429 |
+
console.log(theme.info(`\nCypher Coder veut exécuter la commande suivante :`));
|
| 430 |
console.log(chalk.bgBlack.white(` $ ${args.command} `));
|
| 431 |
|
| 432 |
const { confirmCommand } = await inquirer.prompt([
|
|
|
|
| 456 |
}
|
| 457 |
}
|
| 458 |
|
| 459 |
+
async function executeToolWithFormatter(name, args) {
|
| 460 |
+
console.log(theme.border(` ┌─ [TOOL] ${name}`));
|
| 461 |
+
|
| 462 |
+
const interactive = ['write_file', 'patch_file', 'run_command'].includes(name);
|
| 463 |
+
let interval;
|
| 464 |
+
if (!interactive) {
|
| 465 |
+
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
| 466 |
+
let fIdx = 0;
|
| 467 |
+
process.stdout.write(theme.border(` │ `) + theme.command(frames[fIdx]) + ` running...\r`);
|
| 468 |
+
interval = setInterval(() => {
|
| 469 |
+
fIdx = (fIdx + 1) % frames.length;
|
| 470 |
+
process.stdout.write(theme.border(` │ `) + theme.command(frames[fIdx]) + ` running...\r`);
|
| 471 |
+
}, 80);
|
| 472 |
+
} else {
|
| 473 |
+
console.log(theme.border(` │ `) + theme.info(`waiting for user confirmation...`));
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
const startTime = Date.now();
|
| 477 |
+
const result = await handleToolExecution(name, args);
|
| 478 |
+
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
|
| 479 |
+
|
| 480 |
+
if (interval) {
|
| 481 |
+
clearInterval(interval);
|
| 482 |
+
process.stdout.write(" \r");
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
console.log(theme.border(` └─ `) + theme.agent(`done in ${duration}s`));
|
| 486 |
+
return result;
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
// -----------------------------------------------------
|
| 490 |
// Prompt Système Dynamique & Intelligent
|
| 491 |
// -----------------------------------------------------
|
|
|
|
| 778 |
if (replyMessage.content) {
|
| 779 |
lastAssistantResponse = replyMessage.content;
|
| 780 |
addLog("INFO", "Réponse de l'assistant enregistrée.");
|
| 781 |
+
console.log(theme.agent(`\n▸ Cypher :`));
|
| 782 |
// Rendre le Markdown de l'IA avec formatage ANSI coloré
|
| 783 |
console.log(marked(replyMessage.content));
|
| 784 |
}
|
|
|
|
| 789 |
const name = tc.function.name;
|
| 790 |
const args = JSON.parse(tc.function.arguments);
|
| 791 |
|
| 792 |
+
const result = await executeToolWithFormatter(name, args);
|
|
|
|
| 793 |
|
| 794 |
// Ajouter le résultat de l'outil à la conversation
|
| 795 |
chatMessages.push({
|
|
|
|
| 842 |
switch (commandName.toLowerCase()) {
|
| 843 |
// --- 1. Contrôle de session
|
| 844 |
case '/help':
|
| 845 |
+
console.log(theme.info("\nCYPHER CODER CLI - COMMANDES DISPONIBLES :"));
|
| 846 |
|
| 847 |
+
console.log(theme.command("\nSession :"));
|
| 848 |
console.log(" /help - Affiche ce menu d'aide");
|
| 849 |
console.log(" /exit, /quit - Quitte proprement l'agent");
|
| 850 |
console.log(" /clear - Efface l'écran");
|
|
|
|
| 854 |
console.log(" /about - Infos sur le projet");
|
| 855 |
console.log(" /status - Affiche le statut complet");
|
| 856 |
|
| 857 |
+
console.log(theme.command("\nMémoire et Contexte :"));
|
| 858 |
console.log(" /context - Affiche les fichiers chargés en contexte");
|
| 859 |
console.log(" /context clear - Efface le contexte de fichiers");
|
| 860 |
console.log(" /context save <nom> - Sauvegarde la session actuelle");
|
|
|
|
| 864 |
console.log(" /memory clear - Efface les messages d'historique");
|
| 865 |
console.log(" /tokens - Affiche les statistiques de tokens");
|
| 866 |
|
| 867 |
+
console.log(theme.command("\nHistorique :"));
|
| 868 |
console.log(" /history - Affiche tout l'historique");
|
| 869 |
console.log(" /history clear - Efface l'historique enregistré");
|
| 870 |
console.log(" /history save <fichier> - Exporte l'historique dans un fichier");
|
|
|
|
| 874 |
console.log(" /redo - Relance la dernière requête");
|
| 875 |
console.log(" /undo - Annule la dernière interaction");
|
| 876 |
|
| 877 |
+
console.log(theme.command("\nModèle et Configuration :"));
|
| 878 |
console.log(" /model - Affiche le modèle utilisé");
|
| 879 |
console.log(" /model list - Liste les modèles supportés");
|
| 880 |
console.log(" /model set <nom> - Change de modèle");
|
|
|
|
| 887 |
console.log(" /system reset - Réinitialise le prompt système");
|
| 888 |
console.log(" /stream <on|off> - Active/désactive le streaming");
|
| 889 |
|
| 890 |
+
console.log(theme.command("\nFichiers :"));
|
| 891 |
console.log(" /file load <chemin> - Charge le fichier dans le contexte");
|
| 892 |
console.log(" /file read <chemin> - Lit et affiche un fichier");
|
| 893 |
console.log(" /file write <chemin> - Écrit la dernière réponse dans un fichier");
|
|
|
|
| 898 |
console.log(" /upload <chemin> - Simule l'envoi d'un fichier");
|
| 899 |
console.log(" /download <nom> - Télécharge un fichier");
|
| 900 |
|
| 901 |
+
console.log(theme.command("\nCode et Commandes :"));
|
| 902 |
console.log(" /run - Exécute le dernier bloc de code");
|
| 903 |
console.log(" /run <lang> <code> - Exécute le code fourni");
|
| 904 |
console.log(" /exec <commande> - Lance une commande système");
|
|
|
|
| 909 |
console.log(" /output - Affiche la dernière sortie");
|
| 910 |
console.log(" /output clear - Efface la dernière sortie");
|
| 911 |
|
| 912 |
+
console.log(theme.command("\nOutils et Recherche :"));
|
| 913 |
console.log(" /tools - Liste les outils activés");
|
| 914 |
console.log(" /tool info <nom> - Affiche la description d'un outil");
|
| 915 |
console.log(" /tool enable/disable <n> - Active/désactive un outil");
|
|
|
|
| 917 |
console.log(" /web search <requête> - Recherche en ligne");
|
| 918 |
console.log(" /web fetch <url> - Récupère le contenu d'une URL");
|
| 919 |
|
| 920 |
+
console.log(theme.command("\nThème et Affichage :"));
|
| 921 |
console.log(" /theme <dark|light> - Change le thème");
|
| 922 |
console.log(" /theme list - Liste les thèmes");
|
| 923 |
console.log(" /format <md|plain|json> - Format des réponses");
|
|
|
|
| 927 |
console.log(" /color <on|off> - Colorisation syntaxique");
|
| 928 |
console.log(" /lang <fr|en> - Change la langue");
|
| 929 |
|
| 930 |
+
console.log(theme.command("\nConfiguration et Variable d'env :"));
|
| 931 |
console.log(" /config - Affiche la configuration");
|
| 932 |
console.log(" /config set <key> <val> - Modifie la configuration");
|
| 933 |
console.log(" /config reset - Réinitialise la configuration");
|
|
|
|
| 935 |
console.log(" /env set <VAR> <val> - Définit une variable d'env");
|
| 936 |
console.log(" /api key show/set/clear - Gère les clés d'API");
|
| 937 |
|
| 938 |
+
console.log(theme.command("\nMonitoring et Debug :"));
|
| 939 |
console.log(" /debug <on|off> - Active le mode debug");
|
| 940 |
console.log(" /log - Affiche les logs");
|
| 941 |
console.log(" /log clear/save - Efface ou enregistre les logs");
|
|
|
|
| 945 |
console.log(" /trace - Trace des appels");
|
| 946 |
console.log(" /inspect <var> - Inspecte la configuration interne");
|
| 947 |
|
| 948 |
+
console.log(theme.command("\nAutomatisation :"));
|
| 949 |
console.log(" /macro save/run/list/del - Gère les macros");
|
| 950 |
console.log(" /pipe <cmd1> | <cmd2> - Chaîne deux commandes");
|
| 951 |
console.log(" /loop <n> <commande> - Répète une commande");
|
|
|
|
| 1089 |
if (!lastAssistantResponse) {
|
| 1090 |
console.log(chalk.yellow("Aucune réponse précédente disponible."));
|
| 1091 |
} else {
|
| 1092 |
+
console.log(theme.agent("\nDernière réponse de Cypher :"));
|
| 1093 |
console.log(marked(lastAssistantResponse));
|
| 1094 |
}
|
| 1095 |
break;
|
|
|
|
| 1612 |
}
|
| 1613 |
|
| 1614 |
async function askQuestion() {
|
| 1615 |
+
const username = os.userInfo().username || "local-user";
|
| 1616 |
const { userInput } = await inquirer.prompt([
|
| 1617 |
{
|
| 1618 |
type: 'input',
|
| 1619 |
name: 'userInput',
|
| 1620 |
+
message: theme.user(`❯ ${username} : `),
|
| 1621 |
prefix: ''
|
| 1622 |
}
|
| 1623 |
]);
|
|
|
|
| 1628 |
return askQuestion();
|
| 1629 |
}
|
| 1630 |
|
| 1631 |
+
const time = new Date().toTimeString().split(' ')[0];
|
| 1632 |
+
console.log(theme.border(` └ [timestamp ${time}]`));
|
| 1633 |
+
|
| 1634 |
if (text.startsWith('/')) {
|
| 1635 |
const handled = await handleSlashCommand(text);
|
| 1636 |
if (handled) {
|
|
|
|
| 1648 |
}
|
| 1649 |
|
| 1650 |
async function main() {
|
| 1651 |
+
const username = os.userInfo().username || "local-user";
|
| 1652 |
+
const model = sessionConfig.model;
|
| 1653 |
+
const sessionId = `sess_${Math.random().toString(36).substring(2, 10)}`;
|
| 1654 |
+
|
| 1655 |
console.log(BANNER);
|
| 1656 |
+
console.log(theme.agent(" CYPHER CODER CLI — L'IA experte en developpement local"));
|
| 1657 |
+
console.log(theme.agent(` Cree par DJAKOUA KWANKAM — Institut Universitaire de Technologie de Douala (IUT)`));
|
| 1658 |
+
console.log(theme.border(" ─────────────────────────────────────────────────────────────────"));
|
| 1659 |
+
console.log(theme.info(` Connecte en tant que : @${username}`));
|
| 1660 |
+
console.log(theme.info(` Modele actif : ${model}`));
|
| 1661 |
+
console.log(theme.info(` Session : ${sessionId}`));
|
| 1662 |
+
console.log(theme.border(" ─────────────────────────────────────────────────────────────────"));
|
| 1663 |
+
console.log(theme.command(" Tape /help pour voir les commandes disponibles.\n"));
|
| 1664 |
|
| 1665 |
// Initialiser la session de chat
|
| 1666 |
initChat();
|
|
|
|
| 1669 |
const args = process.argv.slice(2);
|
| 1670 |
if (args.length > 0) {
|
| 1671 |
const initialRequest = args.join(" ");
|
| 1672 |
+
const time = new Date().toTimeString().split(' ')[0];
|
| 1673 |
+
console.log(theme.user(`❯ ${username} : `) + initialRequest);
|
| 1674 |
+
console.log(theme.border(` └ [timestamp ${time}]`));
|
| 1675 |
if (initialRequest.startsWith('/')) {
|
| 1676 |
await handleSlashCommand(initialRequest);
|
| 1677 |
} else {
|