-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·97 lines (90 loc) · 2.72 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env node
import { showHelp, showVersion } from "./src/display.js";
import { automateTask } from "./src/commands/automate.js";
import chalk from "chalk";
import { explainCommand } from "./src/commands/explain.js";
import { fixError } from "./src/commands/fix.js";
import { generateScript } from "./src/commands/generateScript.js";
import { getDefaultModel } from "./src/config.js";
import { removeApiKey } from "./src/config.js";
import { setModel } from "./src/commands/setModel.js";
import { startChatbot } from "./src/commands/chatbot.js";
import { startInteractiveShell } from "./src/commands/interactiveShell.js";
import { systemInfo } from "./src/commands/systemInfo.js";
import { updatePackage } from "./src/commands/update.js";
const args = process.argv.slice(2);
if (args.length === 0) {
// Default: start interactive chatbot mode
// startChatbot();
//TODO: Fix the interactive mode, make it better
startInteractiveShell();
} else {
const command = args[0];
switch (command) {
case "explain": {
const cmdToExplain = args.slice(1).join(" ");
if (!cmdToExplain) {
console.log(chalk.red("Please provide a shell command to explain."));
} else {
explainCommand(cmdToExplain);
}
break;
}
case "generate-script": {
const description = args.slice(1).join(" ");
if (!description) {
console.log(chalk.red("Please provide a description for script generation."));
} else {
generateScript(description);
}
break;
}
case "automate": {
const taskDescription = args.slice(1).join(" ");
if(!taskDescription){
console.log(chalk.red("Please provide a description for the automated task."));
}else {
automateTask(taskDescription);
}
break;
}
case "fix":{
const errorMessage = args.slice(1).join(" ");
if(!errorMessage){
console.log(chalk.red("Please provide an error message for debugging assistance."));
}else{
fixError(errorMessage);
}
break;
}
case "system-info":
systemInfo();
break;
case "set-model": {
const newModel = args[1];
if (!newModel) {
console.log(chalk.red("Please provide a model name."));
} else {
setModel(newModel);
}
break;
}
case "--help":
showHelp();
break;
case "--version":
showVersion();
break;
case "--model":
console.log("Current model:", chalk.green(getDefaultModel()));
break;
case "--remove-api":
removeApiKey();
break;
case "--update":
updatePackage();
break;
default:
console.log(chalk.red("Invalid command. Use --help to see available options."));
}
}