rafaygen-cli 1.0.1 → 1.0.3

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
@@ -48,16 +48,6 @@ program
48
48
 
49
49
  // Handle default command if no args provided -> Start Chat Loop
50
50
  if (process.argv.length === 2) {
51
- console.log(chalk.cyan.bold(`
52
- ____ __ _____
53
- | _ \\ / _| / ____|
54
- | |_) | __ _| |_ __ _ _ _| | __ ___ _ __
55
- | _ < / _\` | _/ _\` | | | | |_ / _ \\ '_ \\
56
- | |_) | (_| | || (_| | |_| |__| | __/ | | |
57
- |____/ \\__,_|_| \\__,_|\\__, \\_____\\___|_| |_|
58
- __/ |
59
- |___/
60
- `));
61
51
  startInteractiveLoop();
62
52
  } else {
63
53
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafaygen-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,6 +21,7 @@
21
21
  "commander": "^14.0.3",
22
22
  "diff": "^9.0.0",
23
23
  "inquirer": "^13.4.3",
24
+ "open": "^11.0.0",
24
25
  "ora": "^9.4.0"
25
26
  },
26
27
  "devDependencies": {
package/src/agent.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getToken, getApiUrl } from "./auth.js";
2
- import { renderBox, renderDiffBox, printError, printStep, printSuccess } from "./ui.js";
2
+ import { startAuthLoop } from "./auth.js";
3
+ import { renderBox, renderDiffBox, printError, printStep, printSuccess, printAsciiLogo, printRandomWelcome } from "./ui.js";
3
4
  import inquirer from "inquirer";
4
5
  import chalk from "chalk";
5
6
  import fs from "fs";
@@ -7,9 +8,10 @@ import path from "path";
7
8
  import { exec } from "child_process";
8
9
 
9
10
  export async function askAgent(promptText) {
10
- const token = getToken();
11
+ let token = getToken();
11
12
  if (!token) {
12
- throw new Error("Not logged in. Please run 'rgcli login <token>' first.");
13
+ await startAuthLoop();
14
+ token = getToken();
13
15
  }
14
16
 
15
17
  printStep("Connecting to RafayGen...");
@@ -48,12 +50,15 @@ export async function askAgent(promptText) {
48
50
  }
49
51
 
50
52
  export async function startInteractiveLoop() {
51
- const token = getToken();
53
+ let token = getToken();
52
54
  if (!token) {
53
- printError("Not logged in. Please run 'rgcli login <token>' first.");
54
- process.exit(1);
55
+ await startAuthLoop();
56
+ token = getToken();
57
+ } else {
58
+ printAsciiLogo();
55
59
  }
56
60
 
61
+ printRandomWelcome();
57
62
  console.log(chalk.gray("Type /help for slash commands, or /exit to quit."));
58
63
 
59
64
  while (true) {
package/src/auth.js CHANGED
@@ -38,3 +38,90 @@ export function getApiUrl() {
38
38
  export function setApiUrl(apiUrl) {
39
39
  saveConfig({ apiUrl });
40
40
  }
41
+
42
+ export async function startAuthLoop() {
43
+ const inquirer = (await import("inquirer")).default;
44
+ const chalk = (await import("chalk")).default;
45
+ const open = (await import("open")).default;
46
+ const { printAsciiLogo, printSuccess } = await import("./ui.js");
47
+
48
+ printAsciiLogo();
49
+ console.log(chalk.yellow("You are not logged in. Let's get you authenticated!\n"));
50
+
51
+ while (true) {
52
+ const { method } = await inquirer.prompt([
53
+ {
54
+ type: "list",
55
+ name: "method",
56
+ message: "How would you like to login to RafayGen?",
57
+ choices: [
58
+ { name: "Browser Login (Recommended)", value: "browser" },
59
+ { name: "Paste Token Manually", value: "token" },
60
+ { name: "Device Code (Headless)", value: "device" },
61
+ { name: "Exit CLI", value: "exit" }
62
+ ]
63
+ }
64
+ ]);
65
+
66
+ if (method === "exit") {
67
+ process.exit(0);
68
+ }
69
+
70
+ if (method === "token") {
71
+ const { token } = await inquirer.prompt([
72
+ {
73
+ type: "password",
74
+ name: "token",
75
+ message: "Paste your RafayGen Personal Access Token:",
76
+ validate: (input) => input.trim() !== "" ? true : "Token cannot be empty"
77
+ }
78
+ ]);
79
+ setToken(token.trim());
80
+ printSuccess("Successfully logged in to RafayGen!");
81
+ return;
82
+ }
83
+
84
+ if (method === "browser") {
85
+ const loginUrl = "https://rafaygen.com/settings/tokens";
86
+ console.log(chalk.cyan(`\nOpening browser to: ${loginUrl}`));
87
+ console.log(chalk.gray("If the browser doesn't open, copy and paste the URL manually."));
88
+ try {
89
+ await open(loginUrl);
90
+ } catch (e) {
91
+ // Ignore open errors
92
+ }
93
+
94
+ const { token } = await inquirer.prompt([
95
+ {
96
+ type: "password",
97
+ name: "token",
98
+ message: "Once you create a token, paste it here:",
99
+ validate: (input) => input.trim() !== "" ? true : "Token cannot be empty"
100
+ }
101
+ ]);
102
+ setToken(token.trim());
103
+ printSuccess("Successfully logged in to RafayGen!");
104
+ return;
105
+ }
106
+
107
+ if (method === "device") {
108
+ const code = Math.floor(100000 + Math.random() * 900000);
109
+ console.log(chalk.magenta.bold(`\nYour Device Code is: ${code}`));
110
+ console.log(chalk.white(`1. Go to https://rafaygen.com/device on your phone or computer.`));
111
+ console.log(chalk.white(`2. Enter the code above.`));
112
+
113
+ console.log(chalk.gray("(Device flow polling is simulated in this CLI version)"));
114
+ const { token } = await inquirer.prompt([
115
+ {
116
+ type: "password",
117
+ name: "token",
118
+ message: "Or just paste the token manually for now:",
119
+ validate: (input) => input.trim() !== "" ? true : "Token cannot be empty"
120
+ }
121
+ ]);
122
+ setToken(token.trim());
123
+ printSuccess("Successfully logged in to RafayGen!");
124
+ return;
125
+ }
126
+ }
127
+ }
package/src/ui.js CHANGED
@@ -68,3 +68,34 @@ export function printSuccess(msg) {
68
68
  export function printStep(msg) {
69
69
  console.log(chalk.cyan.bold("❯ ") + msg);
70
70
  }
71
+
72
+ export function printAsciiLogo() {
73
+ console.log(chalk.cyan.bold(`
74
+ ____ __ _____
75
+ | _ \\ / _| / ____|
76
+ | |_) | __ _| |_ __ _ _ _| | __ ___ _ __
77
+ | _ < / _\` | _/ _\` | | | | |_ / _ \\ '_ \\
78
+ | |_) | (_| | || (_| | |_| |__| | __/ | | |
79
+ |____/ \\__,_|_| \\__,_|\\__, \\_____\\___|_| |_|
80
+ __/ |
81
+ |___/
82
+ `));
83
+ }
84
+
85
+ export function printRandomWelcome() {
86
+ const messages = [
87
+ "Welcome to RafayGen. Ready to architect something beautiful?",
88
+ "RafayGen Agent initialized. Standing by for instructions.",
89
+ "Authentication successful. Let's write some code.",
90
+ "System online. Awaiting your creative vision.",
91
+ "RafayGen connected. What are we building today?",
92
+ "Agent is active. Drop your prompt below.",
93
+ ];
94
+
95
+ const colors = ["green", "cyan", "magenta", "blueBright", "greenBright", "yellowBright"];
96
+
97
+ const randMsg = messages[Math.floor(Math.random() * messages.length)];
98
+ const randColor = colors[Math.floor(Math.random() * colors.length)];
99
+
100
+ console.log(chalk[randColor].bold(`\\n✨ ${randMsg}\\n`));
101
+ }