@devangkumar/dvai 1.0.3 → 1.0.5

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 +17 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devangkumar/dvai",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
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,5 +1,4 @@
1
1
  import { GoogleGenerativeAI } from "@google/generative-ai";
2
- import { Command } from "commander";
3
2
  import ora from "ora";
4
3
  import inquirer from "inquirer";
5
4
 
@@ -8,8 +7,6 @@ const HARDCODED_API_KEY = "AIzaSyDkVgrWXHa7oyPasZGqNOZ-OyA-uYIDtXc";
8
7
  const genAI = new GoogleGenerativeAI(HARDCODED_API_KEY);
9
8
  const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
10
9
 
11
- const program = new Command();
12
-
13
10
  async function startChat(initialHistory = []) {
14
11
  let chatHistory = initialHistory;
15
12
  while (true) {
@@ -38,18 +35,23 @@ async function startChat(initialHistory = []) {
38
35
  }
39
36
  }
40
37
 
41
- program
42
- .name("myai")
43
- .version("1.0.3")
44
- .argument("[prompt]", "Prompt to send to AI")
45
- .action(async (prompt) => {
46
- // If no prompt, start chat immediately
47
- if (!prompt) {
48
- await startChat();
49
- return;
38
+ async function run() {
39
+ const args = process.argv.slice(2);
40
+
41
+ // If no arguments, start chat immediately
42
+ if (args.length === 0) {
43
+ await startChat();
44
+ return;
45
+ }
46
+
47
+ // If "chat" command is used
48
+ if (args[0] === "chat") {
49
+ await startChat();
50
+ return;
50
51
  }
51
52
 
52
- // Otherwise, handle single question
53
+ // Otherwise, treat arguments as a single prompt
54
+ const prompt = args.join(" ");
53
55
  const spinner = ora({ text: "", isSilent: true }).start();
54
56
  try {
55
57
  const result = await model.generateContent(prompt);
@@ -59,6 +61,6 @@ program
59
61
  spinner.stop();
60
62
  console.error("Error:", error.message);
61
63
  }
62
- });
64
+ }
63
65
 
64
- program.parse();
66
+ run();