rafaygen-cli 1.0.0 → 1.0.1

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/bin/rgcli.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import { Command } from "commander";
4
4
  import chalk from "chalk";
5
5
  import { setToken, setApiUrl } from "../src/auth.js";
6
- import { askAgent } from "../src/agent.js";
6
+ import { askAgent, startInteractiveLoop } from "../src/agent.js";
7
7
  import { printSuccess } from "../src/ui.js";
8
8
  import fs from "fs";
9
9
 
@@ -32,14 +32,21 @@ program
32
32
 
33
33
  program
34
34
  .command("ask")
35
- .description("Ask RafayGen to write code, modify files, or run commands")
35
+ .description("Ask RafayGen a one-off question")
36
36
  .argument("<prompt...>", "What do you want to build?")
37
37
  .action((promptWords) => {
38
38
  const prompt = promptWords.join(" ");
39
- askAgent(prompt);
39
+ askAgent(prompt).then(() => process.exit(0));
40
40
  });
41
41
 
42
- // Handle default command if no args provided
42
+ program
43
+ .command("chat")
44
+ .description("Start an interactive chat session")
45
+ .action(() => {
46
+ startInteractiveLoop();
47
+ });
48
+
49
+ // Handle default command if no args provided -> Start Chat Loop
43
50
  if (process.argv.length === 2) {
44
51
  console.log(chalk.cyan.bold(`
45
52
  ____ __ _____
@@ -51,7 +58,7 @@ if (process.argv.length === 2) {
51
58
  __/ |
52
59
  |___/
53
60
  `));
54
- program.help();
61
+ startInteractiveLoop();
62
+ } else {
63
+ program.parse(process.argv);
55
64
  }
56
-
57
- program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafaygen-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/agent.js CHANGED
@@ -9,8 +9,7 @@ import { exec } from "child_process";
9
9
  export async function askAgent(promptText) {
10
10
  const token = getToken();
11
11
  if (!token) {
12
- printError("Not logged in. Please run 'rgcli login <token>' first.");
13
- process.exit(1);
12
+ throw new Error("Not logged in. Please run 'rgcli login <token>' first.");
14
13
  }
15
14
 
16
15
  printStep("Connecting to RafayGen...");
@@ -29,8 +28,6 @@ export async function askAgent(promptText) {
29
28
  throw new Error(`API Error: ${res.statusText}`);
30
29
  }
31
30
 
32
- // Since this is a simple implementation, we'll read the full JSON response.
33
- // In a fully streaming CLI, you'd parse the stream.
34
31
  const data = await res.json();
35
32
 
36
33
  if (data.message) {
@@ -50,6 +47,51 @@ export async function askAgent(promptText) {
50
47
  }
51
48
  }
52
49
 
50
+ export async function startInteractiveLoop() {
51
+ const token = getToken();
52
+ if (!token) {
53
+ printError("Not logged in. Please run 'rgcli login <token>' first.");
54
+ process.exit(1);
55
+ }
56
+
57
+ console.log(chalk.gray("Type /help for slash commands, or /exit to quit."));
58
+
59
+ while (true) {
60
+ const { prompt } = await inquirer.prompt([
61
+ {
62
+ type: "input",
63
+ name: "prompt",
64
+ message: chalk.magenta.bold("rgcli> "),
65
+ prefix: ""
66
+ }
67
+ ]);
68
+
69
+ const input = prompt.trim();
70
+
71
+ if (!input) continue;
72
+
73
+ if (input === "/exit" || input === "/quit") {
74
+ console.log(chalk.gray("Goodbye!"));
75
+ process.exit(0);
76
+ }
77
+
78
+ if (input === "/clear") {
79
+ console.clear();
80
+ continue;
81
+ }
82
+
83
+ if (input === "/help") {
84
+ console.log(chalk.cyan("\\nAvailable Slash Commands:"));
85
+ console.log(chalk.white(" /clear") + chalk.gray(" - Clear the terminal window"));
86
+ console.log(chalk.white(" /exit ") + chalk.gray(" - Exit the interactive shell"));
87
+ console.log(chalk.white(" /help ") + chalk.gray(" - Show this message\\n"));
88
+ continue;
89
+ }
90
+
91
+ await askAgent(input);
92
+ }
93
+ }
94
+
53
95
  async function handleAction(action) {
54
96
  if (action.type === "write") {
55
97
  const filepath = path.resolve(process.cwd(), action.file);