@devangkumar/dvai 1.0.1 → 1.0.2

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/package.json +1 -1
  2. package/src/index.js +13 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devangkumar/dvai",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A powerful AI assistant for your terminal",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { GoogleGenerativeAI } from "@google/generative-ai";
2
2
  import { Command } from "commander";
3
- import chalk from "chalk";
4
3
  import ora from "ora";
5
4
  import inquirer from "inquirer";
6
5
 
@@ -13,17 +12,14 @@ const program = new Command();
13
12
 
14
13
  program
15
14
  .name("myai")
16
- .description("A stunning AI assistant in your terminal")
17
- .version("1.0.1");
15
+ .description("AI Assistant")
16
+ .version("1.0.2");
18
17
 
19
- /**
20
- * Main AI function to get response
21
- */
22
18
  async function getAIResponse(prompt, chatHistory = []) {
23
19
  const spinner = ora({
24
- text: chalk.cyan("AI is thinking..."),
25
- color: "cyan",
26
- spinner: "dots"
20
+ text: "",
21
+ spinner: "dots",
22
+ isSilent: true
27
23
  }).start();
28
24
 
29
25
  try {
@@ -41,7 +37,7 @@ async function getAIResponse(prompt, chatHistory = []) {
41
37
  }
42
38
  } catch (error) {
43
39
  spinner.stop();
44
- console.error(chalk.red("\n✖ AI Error:"), error.message);
40
+ console.error("Error:", error.message);
45
41
  return null;
46
42
  }
47
43
  }
@@ -50,18 +46,15 @@ async function getAIResponse(prompt, chatHistory = []) {
50
46
  * Handle Single Question
51
47
  */
52
48
  program
53
- .argument("[prompt]", "The question you want to ask AI")
49
+ .argument("[prompt]", "Prompt to send to AI")
54
50
  .action(async (prompt) => {
55
51
  if (!prompt) {
56
- displayWelcome();
57
52
  return;
58
53
  }
59
54
 
60
55
  const response = await getAIResponse(prompt);
61
56
  if (response) {
62
- console.log(chalk.blue.bold("\nAI Response:"));
63
- console.log(chalk.white(response));
64
- console.log("\n");
57
+ process.stdout.write(response + "\n");
65
58
  }
66
59
  });
67
60
 
@@ -70,14 +63,8 @@ program
70
63
  */
71
64
  program
72
65
  .command("chat")
73
- .description("Start an interactive chat session")
66
+ .description("Start chat session")
74
67
  .action(async () => {
75
- console.clear();
76
- console.log(chalk.cyan.bold("╔════════════════════════════════════════════╗"));
77
- console.log(chalk.cyan.bold("║ WELCOME TO MYAI TERMINAL ║"));
78
- console.log(chalk.cyan.bold("╚════════════════════════════════════════════╝"));
79
- console.log(chalk.dim("Type 'exit' or 'quit' to end the session.\n"));
80
-
81
68
  let chatHistory = [];
82
69
 
83
70
  while (true) {
@@ -85,36 +72,22 @@ program
85
72
  {
86
73
  type: "input",
87
74
  name: "userInput",
88
- message: chalk.green("? You:"),
89
- validate: (input) => input.trim() !== "" || "Please enter a prompt."
75
+ message: ">",
90
76
  }
91
77
  ]);
92
78
 
93
- if (userInput.toLowerCase() === "exit" || userInput.toLowerCase() === "quit") {
94
- console.log(chalk.yellow("\nGoodbye! 👋\n"));
95
- break;
96
- }
79
+ const cmd = userInput.toLowerCase();
80
+ if (cmd === "exit" || cmd === "quit" || cmd === "bye") break;
97
81
 
98
82
  const response = await getAIResponse(userInput, chatHistory);
99
83
 
100
84
  if (response) {
101
- console.log(chalk.blue.bold("\nAI:"));
102
- console.log(chalk.white(response));
103
- console.log("\n");
85
+ process.stdout.write(response + "\n\n");
104
86
 
105
- // Update history
106
87
  chatHistory.push({ role: "user", parts: [{ text: userInput }] });
107
88
  chatHistory.push({ role: "model", parts: [{ text: response }] });
108
89
  }
109
90
  }
110
91
  });
111
92
 
112
- function displayWelcome() {
113
- console.log(chalk.cyan.bold("\n✨ MyAI Terminal Assistant ✨"));
114
- console.log(chalk.white("Usage:"));
115
- console.log(chalk.dim(" myai \"your question\" ") + chalk.white("- Ask a quick question"));
116
- console.log(chalk.dim(" myai chat ") + chalk.white("- Start interactive session"));
117
- console.log(chalk.dim(" myai --help ") + chalk.white("- Show help\n"));
118
- }
119
-
120
93
  program.parse();