agdi 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/dist/index.js +42 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -323,22 +323,19 @@ import { input, select, password } from "@inquirer/prompts";
|
|
|
323
323
|
import chalk from "chalk";
|
|
324
324
|
async function login() {
|
|
325
325
|
console.log(chalk.cyan.bold("\n\u{1F510} Agdi Authentication\n"));
|
|
326
|
+
console.log(chalk.gray("Configure your API key to use Agdi CLI.\n"));
|
|
326
327
|
const config = loadConfig();
|
|
327
328
|
const provider = await select({
|
|
328
|
-
message: "
|
|
329
|
+
message: "Select your AI provider:",
|
|
329
330
|
choices: [
|
|
330
|
-
{ name: "\u{
|
|
331
|
-
{ name: "\u{1F511}
|
|
331
|
+
{ name: "\u{1F511} Google Gemini (Recommended)", value: "gemini" },
|
|
332
|
+
{ name: "\u{1F511} OpenAI (GPT-4, GPT-5)", value: "openai" },
|
|
333
|
+
{ name: "\u{1F511} Anthropic (Claude)", value: "anthropic" },
|
|
334
|
+
{ name: "\u{1F511} DeepSeek", value: "deepseek" },
|
|
335
|
+
{ name: "\u{1F511} OpenRouter (Multi-model)", value: "openrouter" },
|
|
332
336
|
{ name: "\u{1F3E0} Local LLM (Ollama)", value: "ollama" }
|
|
333
337
|
]
|
|
334
338
|
});
|
|
335
|
-
if (provider === "puter") {
|
|
336
|
-
config.defaultProvider = "puter";
|
|
337
|
-
saveConfig(config);
|
|
338
|
-
console.log(chalk.green("\n\u2705 Using FREE Agdi Cloud (Puter.com)"));
|
|
339
|
-
console.log(chalk.gray("No API key needed - access to 400+ models!\n"));
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
339
|
if (provider === "ollama") {
|
|
343
340
|
const ollamaUrl = await input({
|
|
344
341
|
message: "Ollama server URL:",
|
|
@@ -352,22 +349,11 @@ async function login() {
|
|
|
352
349
|
`));
|
|
353
350
|
return;
|
|
354
351
|
}
|
|
355
|
-
console.log(chalk.cyan("\n\u{1F511} Configure API Keys\n"));
|
|
356
|
-
const keyType = await select({
|
|
357
|
-
message: "Which provider?",
|
|
358
|
-
choices: [
|
|
359
|
-
{ name: "Google Gemini", value: "gemini" },
|
|
360
|
-
{ name: "OpenAI (GPT-4)", value: "openai" },
|
|
361
|
-
{ name: "Anthropic (Claude)", value: "anthropic" },
|
|
362
|
-
{ name: "DeepSeek", value: "deepseek" },
|
|
363
|
-
{ name: "OpenRouter (Multi-model)", value: "openrouter" }
|
|
364
|
-
]
|
|
365
|
-
});
|
|
366
352
|
const apiKey = await password({
|
|
367
|
-
message: `Enter your ${
|
|
353
|
+
message: `Enter your ${provider} API key:`,
|
|
368
354
|
mask: "*"
|
|
369
355
|
});
|
|
370
|
-
switch (
|
|
356
|
+
switch (provider) {
|
|
371
357
|
case "gemini":
|
|
372
358
|
config.geminiApiKey = apiKey;
|
|
373
359
|
break;
|
|
@@ -384,10 +370,10 @@ async function login() {
|
|
|
384
370
|
config.openrouterApiKey = apiKey;
|
|
385
371
|
break;
|
|
386
372
|
}
|
|
387
|
-
config.defaultProvider =
|
|
373
|
+
config.defaultProvider = provider;
|
|
388
374
|
saveConfig(config);
|
|
389
375
|
console.log(chalk.green(`
|
|
390
|
-
\u2705 ${
|
|
376
|
+
\u2705 ${provider} API key saved securely`));
|
|
391
377
|
console.log(chalk.gray("Keys stored in ~/.agdi/config.json\n"));
|
|
392
378
|
}
|
|
393
379
|
async function showStatus() {
|
|
@@ -636,8 +622,24 @@ async function startChat() {
|
|
|
636
622
|
}
|
|
637
623
|
} catch (error) {
|
|
638
624
|
spinner.fail("Error");
|
|
639
|
-
|
|
640
|
-
|
|
625
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
626
|
+
if (errorMessage.includes("429") || errorMessage.includes("quota") || errorMessage.includes("Resource exhausted") || errorMessage.includes("ResourceExhausted")) {
|
|
627
|
+
console.log(chalk2.yellow("\n\u26A0\uFE0F API quota exceeded!"));
|
|
628
|
+
console.log(chalk2.gray("Your API key has run out of credits."));
|
|
629
|
+
console.log(chalk2.gray("Try: Use a different API key or wait for quota reset.\n"));
|
|
630
|
+
} else if (errorMessage.includes("401") || errorMessage.includes("Unauthorized") || errorMessage.includes("Invalid API key")) {
|
|
631
|
+
console.log(chalk2.red("\n\u{1F511} Invalid API key"));
|
|
632
|
+
console.log(chalk2.gray("Please reconfigure your API key:"));
|
|
633
|
+
console.log(chalk2.cyan(" agdi auth\n"));
|
|
634
|
+
} else if (errorMessage.includes("403") || errorMessage.includes("Forbidden")) {
|
|
635
|
+
console.log(chalk2.red("\n\u{1F6AB} Access denied"));
|
|
636
|
+
console.log(chalk2.gray("Your API key doesn't have permission for this operation.\n"));
|
|
637
|
+
} else if (errorMessage.includes("network") || errorMessage.includes("fetch") || errorMessage.includes("ENOTFOUND")) {
|
|
638
|
+
console.log(chalk2.red("\n\u{1F310} Network error"));
|
|
639
|
+
console.log(chalk2.gray("Please check your internet connection.\n"));
|
|
640
|
+
} else {
|
|
641
|
+
console.log(chalk2.red("\n" + errorMessage + "\n"));
|
|
642
|
+
}
|
|
641
643
|
}
|
|
642
644
|
}
|
|
643
645
|
}
|
|
@@ -755,12 +757,12 @@ program.command("init").description("Create a new project interactively").action
|
|
|
755
757
|
process.exit(1);
|
|
756
758
|
}
|
|
757
759
|
});
|
|
758
|
-
program.command("generate <prompt>").alias("g").description("Generate an app from a prompt").option("-p, --provider <provider>", "AI provider (
|
|
760
|
+
program.command("generate <prompt>").alias("g").description("Generate an app from a prompt").option("-p, --provider <provider>", "AI provider (gemini, openai, anthropic)", "gemini").option("-m, --model <model>", "AI model to use", "gemini-2.5-flash").option("-o, --output <dir>", "Output directory", "./generated-app").action(async (prompt, options) => {
|
|
759
761
|
const config = loadConfig();
|
|
760
762
|
const provider = options.provider;
|
|
761
|
-
if (provider === "gemini"
|
|
762
|
-
console.error(chalk3.red("\u274C No Gemini API key configured.
|
|
763
|
-
console.error(chalk3.yellow("\u{1F4A1}
|
|
763
|
+
if (!config.geminiApiKey && provider === "gemini") {
|
|
764
|
+
console.error(chalk3.red("\u274C No Gemini API key configured."));
|
|
765
|
+
console.error(chalk3.yellow("\u{1F4A1} Run: agdi auth"));
|
|
764
766
|
process.exit(1);
|
|
765
767
|
}
|
|
766
768
|
const spinner = ora2(`Generating app with ${chalk3.cyan(options.model)}...`).start();
|
|
@@ -780,7 +782,15 @@ program.command("generate <prompt>").alias("g").description("Generate an app fro
|
|
|
780
782
|
spinner.succeed(`App generated in ${chalk3.cyan(options.output)}`);
|
|
781
783
|
} catch (error) {
|
|
782
784
|
spinner.fail("Generation failed");
|
|
783
|
-
|
|
785
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
786
|
+
if (errorMessage.includes("429") || errorMessage.includes("quota") || errorMessage.includes("Resource exhausted")) {
|
|
787
|
+
console.log(chalk3.yellow("\n\u26A0\uFE0F API quota exceeded!"));
|
|
788
|
+
console.log(chalk3.gray("Your API key has run out of credits.\n"));
|
|
789
|
+
} else if (errorMessage.includes("401") || errorMessage.includes("Unauthorized")) {
|
|
790
|
+
console.log(chalk3.red("\n\u{1F511} Invalid API key. Run: agdi auth\n"));
|
|
791
|
+
} else {
|
|
792
|
+
console.error(chalk3.red(errorMessage));
|
|
793
|
+
}
|
|
784
794
|
process.exit(1);
|
|
785
795
|
}
|
|
786
796
|
});
|