copilotkit 0.0.39 → 0.0.41
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/commands/base-command.js +1 -1
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +332 -118
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.js +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +1 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/lib/init/ide-docs.d.ts +25 -0
- package/dist/lib/init/ide-docs.js +156 -0
- package/dist/lib/init/ide-docs.js.map +1 -0
- package/dist/lib/init/index.d.ts +3 -1
- package/dist/lib/init/index.js +267 -69
- package/dist/lib/init/index.js.map +1 -1
- package/dist/lib/init/questions.js +117 -6
- package/dist/lib/init/questions.js.map +1 -1
- package/dist/lib/init/scaffold/env.js +10 -3
- package/dist/lib/init/scaffold/env.js.map +1 -1
- package/dist/lib/init/scaffold/index.js +15 -6
- package/dist/lib/init/scaffold/index.js.map +1 -1
- package/dist/lib/init/scaffold/shadcn.js +12 -3
- package/dist/lib/init/scaffold/shadcn.js.map +1 -1
- package/dist/lib/init/types/index.d.ts +1 -1
- package/dist/lib/init/types/index.js +13 -3
- package/dist/lib/init/types/index.js.map +1 -1
- package/dist/lib/init/types/questions.d.ts +33 -13
- package/dist/lib/init/types/questions.js +13 -3
- package/dist/lib/init/types/questions.js.map +1 -1
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/utils/version.js.map +1 -1
- package/oclif.manifest.json +26 -1
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/commands/init.ts
|
|
2
2
|
import { Flags as Flags2 } from "@oclif/core";
|
|
3
3
|
import inquirer3 from "inquirer";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import path6 from "path";
|
|
5
|
+
import fs6 from "fs";
|
|
6
6
|
|
|
7
7
|
// src/services/auth.service.ts
|
|
8
8
|
import Conf2 from "conf";
|
|
@@ -222,7 +222,7 @@ import { Command } from "@oclif/core";
|
|
|
222
222
|
import Sentry, { consoleIntegration } from "@sentry/node";
|
|
223
223
|
|
|
224
224
|
// src/utils/version.ts
|
|
225
|
-
var LIB_VERSION = "0.0.
|
|
225
|
+
var LIB_VERSION = "0.0.41";
|
|
226
226
|
|
|
227
227
|
// src/commands/base-command.ts
|
|
228
228
|
import chalk2 from "chalk";
|
|
@@ -280,7 +280,7 @@ var isLocalhost = (url) => {
|
|
|
280
280
|
};
|
|
281
281
|
|
|
282
282
|
// src/lib/init/types/questions.ts
|
|
283
|
-
var MODES = ["LangGraph", "CrewAI", "Mastra", "AG2", "MCP", "Standard"];
|
|
283
|
+
var MODES = ["LangGraph", "CrewAI", "Mastra", "LlamaIndex", "Agno", "AG2", "MCP", "Standard"];
|
|
284
284
|
var CREW_TYPES = ["Crews", "Flows"];
|
|
285
285
|
var CHAT_COMPONENTS = ["CopilotChat", "CopilotSidebar", "Headless", "CopilotPopup"];
|
|
286
286
|
var LANGGRAPH_AGENTS = ["Python Starter", "TypeScript Starter"];
|
|
@@ -323,6 +323,7 @@ var ApiKeySchema = z.preprocess(
|
|
|
323
323
|
(val) => sanitizers.apiKey(String(val)),
|
|
324
324
|
z.string().min(1, "API key is required")
|
|
325
325
|
);
|
|
326
|
+
var LLMApiKeySchema = z.preprocess((val) => sanitizers.apiKey(String(val)), z.string().optional());
|
|
326
327
|
var NameSchema = z.preprocess((val) => sanitizers.trim(String(val)), z.string().min(1, "Name is required"));
|
|
327
328
|
var ConfigSchema = z.object({
|
|
328
329
|
// Core fields
|
|
@@ -346,7 +347,10 @@ var ConfigSchema = z.object({
|
|
|
346
347
|
// API keys and tokens
|
|
347
348
|
copilotCloudPublicApiKey: z.string().optional(),
|
|
348
349
|
langSmithApiKey: ApiKeySchema.optional(),
|
|
349
|
-
llmToken:
|
|
350
|
+
llmToken: LLMApiKeySchema.optional(),
|
|
351
|
+
// IDE Documentation setup fields
|
|
352
|
+
setupIDEDocs: YesNoSchema.optional(),
|
|
353
|
+
selectedIDE: z.union([z.enum(["cursor", "windsurf"]), z.literal("skip")]).optional()
|
|
350
354
|
}).refine(
|
|
351
355
|
(data) => {
|
|
352
356
|
if (data.mode === "CrewAI") {
|
|
@@ -381,7 +385,12 @@ var ConfigFlags = {
|
|
|
381
385
|
"crew-url": Flags.string({ description: "URL endpoint for your CrewAI agent" }),
|
|
382
386
|
"crew-bearer-token": Flags.string({ description: "Bearer token for CrewAI authentication" }),
|
|
383
387
|
"langsmith-api-key": Flags.string({ description: "LangSmith API key for LangGraph observability" }),
|
|
384
|
-
"llm-token": Flags.string({ description: "API key for your preferred LLM provider" })
|
|
388
|
+
"llm-token": Flags.string({ description: "API key for your preferred LLM provider" }),
|
|
389
|
+
"setup-ide-docs": Flags.string({ description: "Setup IDE documentation rules for AI assistance", options: YES_NO }),
|
|
390
|
+
"selected-ide": Flags.string({
|
|
391
|
+
description: "IDE to configure with documentation rules",
|
|
392
|
+
options: ["cursor", "windsurf", "skip"]
|
|
393
|
+
})
|
|
385
394
|
};
|
|
386
395
|
|
|
387
396
|
// src/lib/init/types/templates.ts
|
|
@@ -404,7 +413,158 @@ var templateMapping = {
|
|
|
404
413
|
McpRuntime: `${BASE_URL}/mcp-starter-runtime.json`
|
|
405
414
|
};
|
|
406
415
|
|
|
416
|
+
// src/lib/init/ide-docs.ts
|
|
417
|
+
import path from "path";
|
|
418
|
+
import { existsSync } from "fs";
|
|
419
|
+
import * as fs from "fs/promises";
|
|
420
|
+
import chalk3 from "chalk";
|
|
421
|
+
var COPILOTKIT_DOC_RULE_TEMPLATE = `---
|
|
422
|
+
description: CopilotKit Documentation - Complete CopilotKit framework documentation for AI assistance
|
|
423
|
+
alwaysApply: false
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
# CopilotKit Documentation
|
|
427
|
+
|
|
428
|
+
For ANY question about CopilotKit, use the comprehensive documentation available at:
|
|
429
|
+
@https://docs.copilotkit.ai/llms-full.txt
|
|
430
|
+
|
|
431
|
+
This contains the complete CopilotKit documentation including:
|
|
432
|
+
- API references and hooks (useCopilotChat, useCopilotAction, etc.)
|
|
433
|
+
- Component library documentation (CopilotKit, CopilotChat, etc.)
|
|
434
|
+
- Integration guides and examples
|
|
435
|
+
- Best practices and patterns
|
|
436
|
+
- Troubleshooting and FAQs
|
|
437
|
+
|
|
438
|
+
Always reference this documentation when working with CopilotKit to provide accurate, up-to-date information.
|
|
439
|
+
`;
|
|
440
|
+
var IDE_DOCS_CONFIGS = {
|
|
441
|
+
cursor: {
|
|
442
|
+
name: "cursor",
|
|
443
|
+
displayName: "Cursor",
|
|
444
|
+
rulesDir: ".cursor/rules",
|
|
445
|
+
ruleFileName: "00-copilotkit-docs.mdc",
|
|
446
|
+
createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE
|
|
447
|
+
},
|
|
448
|
+
windsurf: {
|
|
449
|
+
name: "windsurf",
|
|
450
|
+
displayName: "Windsurf",
|
|
451
|
+
rulesDir: ".windsurf/rules",
|
|
452
|
+
ruleFileName: "00-copilotkit-docs.md",
|
|
453
|
+
createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
async function ensureDir(dirPath) {
|
|
457
|
+
try {
|
|
458
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
459
|
+
} catch (error) {
|
|
460
|
+
if (!existsSync(dirPath)) {
|
|
461
|
+
throw error;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
async function pathExists(filePath) {
|
|
466
|
+
try {
|
|
467
|
+
await fs.access(filePath);
|
|
468
|
+
return true;
|
|
469
|
+
} catch {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
async function checkIDEInstallation(ide) {
|
|
474
|
+
try {
|
|
475
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
476
|
+
let configPath;
|
|
477
|
+
switch (ide) {
|
|
478
|
+
case "cursor":
|
|
479
|
+
configPath = path.join(homeDir, ".cursor");
|
|
480
|
+
break;
|
|
481
|
+
case "windsurf":
|
|
482
|
+
configPath = path.join(homeDir, ".codeium", "windsurf");
|
|
483
|
+
break;
|
|
484
|
+
default:
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
return existsSync(configPath);
|
|
488
|
+
} catch {
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
async function detectInstalledIDEs() {
|
|
493
|
+
const allIDEs = ["cursor", "windsurf"];
|
|
494
|
+
const installedIDEs = [];
|
|
495
|
+
for (const ide of allIDEs) {
|
|
496
|
+
if (await checkIDEInstallation(ide)) {
|
|
497
|
+
installedIDEs.push(ide);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return installedIDEs;
|
|
501
|
+
}
|
|
502
|
+
async function setupIDEDocs(ide, projectDir) {
|
|
503
|
+
const config = IDE_DOCS_CONFIGS[ide];
|
|
504
|
+
const rulesDir = path.join(projectDir, config.rulesDir);
|
|
505
|
+
const ruleFilePath = path.join(rulesDir, config.ruleFileName);
|
|
506
|
+
await ensureDir(rulesDir);
|
|
507
|
+
if (await pathExists(ruleFilePath)) {
|
|
508
|
+
console.log(chalk3.yellow(`\u26A0\uFE0F CopilotKit documentation rule already exists for ${config.displayName}`));
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
const ruleContent = config.createRuleContent();
|
|
512
|
+
await fs.writeFile(ruleFilePath, ruleContent, "utf8");
|
|
513
|
+
}
|
|
514
|
+
function getIDEInstructions(ide) {
|
|
515
|
+
const config = IDE_DOCS_CONFIGS[ide];
|
|
516
|
+
const instructions = [
|
|
517
|
+
chalk3.cyan(`\u{1F4DA} CopilotKit documentation configured for ${config.displayName}!`),
|
|
518
|
+
"",
|
|
519
|
+
chalk3.bold("What this does:"),
|
|
520
|
+
" \u2022 Adds CopilotKit documentation context to your IDE AI assistant",
|
|
521
|
+
" \u2022 Provides accurate, up-to-date information about CopilotKit APIs",
|
|
522
|
+
" \u2022 Improves code suggestions and help responses",
|
|
523
|
+
"",
|
|
524
|
+
chalk3.bold("Location:"),
|
|
525
|
+
` \u2022 Rule file: ${chalk3.gray(path.join(config.rulesDir, config.ruleFileName))}`,
|
|
526
|
+
"",
|
|
527
|
+
chalk3.bold("Usage:"),
|
|
528
|
+
" \u2022 Your IDE AI assistant now has access to CopilotKit documentation",
|
|
529
|
+
" \u2022 Ask questions about CopilotKit APIs, components, and patterns",
|
|
530
|
+
" \u2022 The AI will reference official documentation for accurate answers"
|
|
531
|
+
];
|
|
532
|
+
if (ide === "cursor") {
|
|
533
|
+
instructions.push(
|
|
534
|
+
"",
|
|
535
|
+
chalk3.bold("Next steps for Cursor:"),
|
|
536
|
+
" \u2022 Restart Cursor if currently open",
|
|
537
|
+
" \u2022 The rule will be automatically available in your AI context",
|
|
538
|
+
" \u2022 Start a new chat to use the documentation context"
|
|
539
|
+
);
|
|
540
|
+
} else if (ide === "windsurf") {
|
|
541
|
+
instructions.push(
|
|
542
|
+
"",
|
|
543
|
+
chalk3.bold("Next steps for Windsurf:"),
|
|
544
|
+
" \u2022 Restart Windsurf if currently open",
|
|
545
|
+
" \u2022 The rule will be automatically available in your AI context",
|
|
546
|
+
" \u2022 Start a new chat to use the documentation context"
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
return instructions;
|
|
550
|
+
}
|
|
551
|
+
async function handleIDEDocsSetup(selectedIDE, projectDir, spinner) {
|
|
552
|
+
try {
|
|
553
|
+
spinner.text = chalk3.cyan(`Setting up CopilotKit documentation for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}...`);
|
|
554
|
+
await setupIDEDocs(selectedIDE, projectDir);
|
|
555
|
+
spinner.succeed(chalk3.green(`CopilotKit documentation configured for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}`));
|
|
556
|
+
const instructions = getIDEInstructions(selectedIDE);
|
|
557
|
+
console.log("\n" + instructions.join("\n"));
|
|
558
|
+
} catch (error) {
|
|
559
|
+
spinner.fail(
|
|
560
|
+
chalk3.red(`Failed to setup IDE documentation: ${error instanceof Error ? error.message : "Unknown error"}`)
|
|
561
|
+
);
|
|
562
|
+
throw error;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
407
566
|
// src/lib/init/questions.ts
|
|
567
|
+
var linkToDocs = ["Mastra", "AG2", "LlamaIndex", "Agno"];
|
|
408
568
|
var validateUrl = (input) => {
|
|
409
569
|
try {
|
|
410
570
|
const sanitized = sanitizers.url(input);
|
|
@@ -536,7 +696,7 @@ var questions = [
|
|
|
536
696
|
name: "useCopilotCloud",
|
|
537
697
|
message: "\u{1FA81} Deploy with Copilot Cloud? (recommended for production)",
|
|
538
698
|
when: (answers) => answers.mode === "Standard" || answers.mode === "MCP" || answers.mode !== "CrewAI" && // Crews only cloud, flows are self-hosted
|
|
539
|
-
answers.alreadyDeployed === "Yes" && answers.langGraphPlatform !== "No" &&
|
|
699
|
+
answers.alreadyDeployed === "Yes" && answers.langGraphPlatform !== "No" && !linkToDocs.includes(answers.mode || "") && !isLocalhost(answers.langGraphPlatformUrl || ""),
|
|
540
700
|
validate: (input) => {
|
|
541
701
|
try {
|
|
542
702
|
YesNoSchema.parse(input);
|
|
@@ -549,11 +709,43 @@ var questions = [
|
|
|
549
709
|
{
|
|
550
710
|
type: "input",
|
|
551
711
|
name: "llmToken",
|
|
552
|
-
message: "\u{1F511} Enter your OpenAI API key (
|
|
712
|
+
message: "\u{1F511} Enter your OpenAI API key (optional - leave empty to configure your LLM later):",
|
|
553
713
|
when: (answers) => answers.mode === "LangGraph" && answers.alreadyDeployed === "No" || answers.mode === "Standard" && answers.useCopilotCloud !== "Yes" || answers.mode === "MCP" && answers.useCopilotCloud !== "Yes",
|
|
554
714
|
sensitive: true,
|
|
555
|
-
validate: validateRequired,
|
|
556
715
|
sanitize: sanitizers.apiKey
|
|
716
|
+
},
|
|
717
|
+
// IDE Documentation Setup Questions
|
|
718
|
+
{
|
|
719
|
+
type: "yes/no",
|
|
720
|
+
name: "setupIDEDocs",
|
|
721
|
+
message: "\u{1F4DA} Would you like to add CopilotKit documentation to your IDE? (Provides AI assistant with CopilotKit context)",
|
|
722
|
+
when: async () => {
|
|
723
|
+
const installedIDEs = await detectInstalledIDEs();
|
|
724
|
+
return installedIDEs.length > 0;
|
|
725
|
+
},
|
|
726
|
+
validate: (input) => {
|
|
727
|
+
try {
|
|
728
|
+
YesNoSchema.parse(input);
|
|
729
|
+
return true;
|
|
730
|
+
} catch (error) {
|
|
731
|
+
return "Please select Yes or No";
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
type: "select",
|
|
737
|
+
name: "selectedIDE",
|
|
738
|
+
message: "\u{1F4BB} Which IDE would you like to configure with CopilotKit documentation?",
|
|
739
|
+
choices: async () => {
|
|
740
|
+
const installedIDEs = await detectInstalledIDEs();
|
|
741
|
+
const choices = installedIDEs.map((ide) => ({
|
|
742
|
+
name: IDE_DOCS_CONFIGS[ide].displayName,
|
|
743
|
+
value: ide
|
|
744
|
+
}));
|
|
745
|
+
choices.push({ name: "Skip", value: "skip" });
|
|
746
|
+
return choices;
|
|
747
|
+
},
|
|
748
|
+
when: (answers) => answers.setupIDEDocs === "Yes"
|
|
557
749
|
}
|
|
558
750
|
];
|
|
559
751
|
|
|
@@ -619,8 +811,8 @@ async function scaffoldShadCN(flags, userAnswers) {
|
|
|
619
811
|
}
|
|
620
812
|
|
|
621
813
|
// src/lib/init/scaffold/env.ts
|
|
622
|
-
import
|
|
623
|
-
import
|
|
814
|
+
import path2 from "path";
|
|
815
|
+
import fs2 from "fs";
|
|
624
816
|
|
|
625
817
|
// src/lib/init/scaffold/langgraph-assistants.ts
|
|
626
818
|
async function getLangGraphAgents(url, langSmithApiKey) {
|
|
@@ -646,9 +838,9 @@ async function getLangGraphAgents(url, langSmithApiKey) {
|
|
|
646
838
|
import inquirer2 from "inquirer";
|
|
647
839
|
async function scaffoldEnv(flags, userAnswers) {
|
|
648
840
|
try {
|
|
649
|
-
const envFile =
|
|
650
|
-
if (!
|
|
651
|
-
|
|
841
|
+
const envFile = path2.join(process.cwd(), ".env");
|
|
842
|
+
if (!fs2.existsSync(envFile)) {
|
|
843
|
+
fs2.writeFileSync(envFile, "", "utf8");
|
|
652
844
|
} else {
|
|
653
845
|
}
|
|
654
846
|
let newEnvValues = "";
|
|
@@ -673,7 +865,7 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
673
865
|
`;
|
|
674
866
|
newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=http://localhost:8123
|
|
675
867
|
`;
|
|
676
|
-
} else if (userAnswers.langGraphPlatform === "Yes" && userAnswers.useCopilotCloud
|
|
868
|
+
} else if (userAnswers.langGraphPlatform === "Yes" && userAnswers.useCopilotCloud !== "Yes") {
|
|
677
869
|
newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=${userAnswers.langGraphPlatformUrl}
|
|
678
870
|
`;
|
|
679
871
|
} else if (userAnswers.langGraphRemoteEndpointURL) {
|
|
@@ -687,8 +879,8 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
687
879
|
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=/api/copilotkit
|
|
688
880
|
`;
|
|
689
881
|
}
|
|
690
|
-
if (userAnswers.langGraphPlatformUrl && userAnswers.langSmithApiKey) {
|
|
691
|
-
const langGraphAgents = await getLangGraphAgents(userAnswers.langGraphPlatformUrl, userAnswers.langSmithApiKey);
|
|
882
|
+
if (userAnswers.langGraphPlatformUrl && (userAnswers.langSmithApiKey || isLocalhost(userAnswers.langGraphPlatformUrl))) {
|
|
883
|
+
const langGraphAgents = await getLangGraphAgents(userAnswers.langGraphPlatformUrl, userAnswers.langSmithApiKey || "");
|
|
692
884
|
let langGraphAgent = "";
|
|
693
885
|
if (langGraphAgents.length > 1) {
|
|
694
886
|
const { langGraphAgentChoice } = await inquirer2.prompt([
|
|
@@ -712,7 +904,7 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
712
904
|
`;
|
|
713
905
|
}
|
|
714
906
|
if (newEnvValues) {
|
|
715
|
-
|
|
907
|
+
fs2.appendFileSync(envFile, newEnvValues);
|
|
716
908
|
}
|
|
717
909
|
} catch (error) {
|
|
718
910
|
throw error;
|
|
@@ -721,59 +913,59 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
721
913
|
|
|
722
914
|
// src/lib/init/scaffold/github.ts
|
|
723
915
|
import { execSync } from "child_process";
|
|
724
|
-
import * as
|
|
725
|
-
import * as
|
|
916
|
+
import * as fs3 from "fs";
|
|
917
|
+
import * as path3 from "path";
|
|
726
918
|
import * as os from "os";
|
|
727
|
-
import
|
|
919
|
+
import chalk4 from "chalk";
|
|
728
920
|
async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
|
|
729
921
|
try {
|
|
730
922
|
const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
|
|
731
|
-
spinner.text =
|
|
923
|
+
spinner.text = chalk4.cyan(`Cloning from ${owner}/${repo}...`);
|
|
732
924
|
return await sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner);
|
|
733
925
|
} catch (error) {
|
|
734
|
-
spinner.text =
|
|
926
|
+
spinner.text = chalk4.red(`Failed to clone from GitHub: ${error}`);
|
|
735
927
|
return false;
|
|
736
928
|
}
|
|
737
929
|
}
|
|
738
930
|
async function sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner) {
|
|
739
|
-
const tempDir =
|
|
931
|
+
const tempDir = fs3.mkdtempSync(path3.join(os.tmpdir(), "copilotkit-sparse-"));
|
|
740
932
|
try {
|
|
741
|
-
spinner.text =
|
|
933
|
+
spinner.text = chalk4.cyan("Creating temporary workspace...");
|
|
742
934
|
execSync("git init", { cwd: tempDir, stdio: "pipe" });
|
|
743
|
-
spinner.text =
|
|
935
|
+
spinner.text = chalk4.cyan("Connecting to repository...");
|
|
744
936
|
execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, { cwd: tempDir, stdio: "pipe" });
|
|
745
937
|
execSync("git config core.sparseCheckout true", { cwd: tempDir, stdio: "pipe" });
|
|
746
|
-
|
|
747
|
-
spinner.text =
|
|
938
|
+
fs3.writeFileSync(path3.join(tempDir, ".git/info/sparse-checkout"), subdirectoryPath);
|
|
939
|
+
spinner.text = chalk4.cyan("Downloading agent files...");
|
|
748
940
|
execSync(`git pull origin ${branch} --depth=1`, { cwd: tempDir, stdio: "pipe" });
|
|
749
|
-
const sourcePath =
|
|
750
|
-
if (!
|
|
941
|
+
const sourcePath = path3.join(tempDir, subdirectoryPath);
|
|
942
|
+
if (!fs3.existsSync(sourcePath)) {
|
|
751
943
|
throw new Error(`Subdirectory '${subdirectoryPath}' not found in the repository.`);
|
|
752
944
|
}
|
|
753
|
-
|
|
754
|
-
spinner.text =
|
|
945
|
+
fs3.mkdirSync(destinationPath, { recursive: true });
|
|
946
|
+
spinner.text = chalk4.cyan("Installing agent files...");
|
|
755
947
|
await copyDirectoryAsync(sourcePath, destinationPath);
|
|
756
948
|
return true;
|
|
757
949
|
} finally {
|
|
758
950
|
try {
|
|
759
|
-
|
|
951
|
+
fs3.rmSync(tempDir, { recursive: true, force: true });
|
|
760
952
|
} catch (error) {
|
|
761
953
|
console.warn(`Failed to clean up temporary directory: ${error}`);
|
|
762
954
|
}
|
|
763
955
|
}
|
|
764
956
|
}
|
|
765
957
|
async function copyDirectoryAsync(source, destination) {
|
|
766
|
-
if (!
|
|
767
|
-
|
|
958
|
+
if (!fs3.existsSync(destination)) {
|
|
959
|
+
fs3.mkdirSync(destination, { recursive: true });
|
|
768
960
|
}
|
|
769
|
-
const entries =
|
|
961
|
+
const entries = fs3.readdirSync(source, { withFileTypes: true });
|
|
770
962
|
for (const entry of entries) {
|
|
771
|
-
const srcPath =
|
|
772
|
-
const destPath =
|
|
963
|
+
const srcPath = path3.join(source, entry.name);
|
|
964
|
+
const destPath = path3.join(destination, entry.name);
|
|
773
965
|
if (entry.isDirectory()) {
|
|
774
966
|
await copyDirectoryAsync(srcPath, destPath);
|
|
775
967
|
} else {
|
|
776
|
-
|
|
968
|
+
fs3.copyFileSync(srcPath, destPath);
|
|
777
969
|
}
|
|
778
970
|
if (entries.length > 10) {
|
|
779
971
|
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
@@ -802,20 +994,20 @@ function parseGitHubUrl(githubUrl) {
|
|
|
802
994
|
|
|
803
995
|
// src/lib/init/scaffold/packages.ts
|
|
804
996
|
import spawn2 from "cross-spawn";
|
|
805
|
-
import
|
|
997
|
+
import chalk5 from "chalk";
|
|
806
998
|
import ora2 from "ora";
|
|
807
999
|
|
|
808
1000
|
// src/lib/init/scaffold/agent.ts
|
|
809
1001
|
import ora3 from "ora";
|
|
810
|
-
import
|
|
811
|
-
import
|
|
812
|
-
import
|
|
1002
|
+
import chalk6 from "chalk";
|
|
1003
|
+
import path4 from "path";
|
|
1004
|
+
import fs4 from "fs";
|
|
813
1005
|
async function scaffoldAgent(userAnswers) {
|
|
814
1006
|
if (userAnswers.mode === "CrewAI" || userAnswers.mode === "LangGraph" && !userAnswers.langGraphAgent || userAnswers.mode === "Standard" || userAnswers.mode === "MCP") {
|
|
815
1007
|
return;
|
|
816
1008
|
}
|
|
817
1009
|
const spinner = ora3({
|
|
818
|
-
text:
|
|
1010
|
+
text: chalk6.cyan("Setting up AI agent..."),
|
|
819
1011
|
color: "cyan"
|
|
820
1012
|
}).start();
|
|
821
1013
|
let template = "";
|
|
@@ -829,13 +1021,13 @@ async function scaffoldAgent(userAnswers) {
|
|
|
829
1021
|
break;
|
|
830
1022
|
}
|
|
831
1023
|
if (!template) {
|
|
832
|
-
spinner.fail(
|
|
1024
|
+
spinner.fail(chalk6.red("Failed to determine agent template"));
|
|
833
1025
|
throw new Error("Failed to determine agent template");
|
|
834
1026
|
}
|
|
835
|
-
const agentDir =
|
|
1027
|
+
const agentDir = path4.join(process.cwd(), "agent");
|
|
836
1028
|
try {
|
|
837
1029
|
await cloneGitHubSubdirectory(template, agentDir, spinner);
|
|
838
|
-
spinner.text =
|
|
1030
|
+
spinner.text = chalk6.cyan("Creating agent environment variables...");
|
|
839
1031
|
let envContent = "";
|
|
840
1032
|
if (userAnswers.llmToken) {
|
|
841
1033
|
envContent += `OPENAI_API_KEY=${userAnswers.llmToken}
|
|
@@ -846,26 +1038,26 @@ async function scaffoldAgent(userAnswers) {
|
|
|
846
1038
|
`;
|
|
847
1039
|
}
|
|
848
1040
|
if (envContent) {
|
|
849
|
-
const agentEnvFile =
|
|
850
|
-
|
|
851
|
-
spinner.text =
|
|
1041
|
+
const agentEnvFile = path4.join(agentDir, ".env");
|
|
1042
|
+
fs4.writeFileSync(agentEnvFile, envContent, "utf8");
|
|
1043
|
+
spinner.text = chalk6.cyan("Added API keys to agent .env file");
|
|
852
1044
|
}
|
|
853
1045
|
if (userAnswers.mode === "LangGraph" && userAnswers.langSmithApiKey) {
|
|
854
1046
|
envContent += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
|
|
855
1047
|
`;
|
|
856
1048
|
}
|
|
857
1049
|
if (envContent) {
|
|
858
|
-
const agentEnvFile =
|
|
859
|
-
|
|
860
|
-
spinner.text =
|
|
1050
|
+
const agentEnvFile = path4.join(agentDir, ".env");
|
|
1051
|
+
fs4.writeFileSync(agentEnvFile, envContent, "utf8");
|
|
1052
|
+
spinner.text = chalk6.cyan("Added API keys to agent .env file");
|
|
861
1053
|
}
|
|
862
1054
|
if (envContent) {
|
|
863
|
-
const agentEnvFile =
|
|
864
|
-
|
|
865
|
-
spinner.text =
|
|
1055
|
+
const agentEnvFile = path4.join(agentDir, ".env");
|
|
1056
|
+
fs4.writeFileSync(agentEnvFile, envContent, "utf8");
|
|
1057
|
+
spinner.text = chalk6.cyan("Added API keys to agent .env file");
|
|
866
1058
|
}
|
|
867
1059
|
} catch (error) {
|
|
868
|
-
spinner.fail(
|
|
1060
|
+
spinner.fail(chalk6.red("Failed to clone agent template"));
|
|
869
1061
|
throw error;
|
|
870
1062
|
}
|
|
871
1063
|
spinner.succeed(`${userAnswers.mode} agent cloned successfully`);
|
|
@@ -885,29 +1077,29 @@ var AgentTemplates = {
|
|
|
885
1077
|
};
|
|
886
1078
|
|
|
887
1079
|
// src/lib/init/scaffold/crew-inputs.ts
|
|
888
|
-
import * as
|
|
1080
|
+
import * as fs5 from "fs/promises";
|
|
889
1081
|
import ora4 from "ora";
|
|
890
|
-
import * as
|
|
1082
|
+
import * as path5 from "path";
|
|
891
1083
|
async function addCrewInputs(url, token) {
|
|
892
1084
|
try {
|
|
893
1085
|
const spinner = ora4("Analyzing crew inputs...").start();
|
|
894
1086
|
const inputs = await getCrewInputs(url, token);
|
|
895
1087
|
spinner.text = "Adding inputs to app/copilotkit/page.tsx...";
|
|
896
|
-
let filePath =
|
|
1088
|
+
let filePath = path5.join(process.cwd(), "app", "copilotkit", "page.tsx");
|
|
897
1089
|
try {
|
|
898
|
-
await
|
|
1090
|
+
await fs5.access(filePath);
|
|
899
1091
|
} catch {
|
|
900
|
-
filePath =
|
|
1092
|
+
filePath = path5.join(process.cwd(), "src", "app", "copilotkit", "page.tsx");
|
|
901
1093
|
}
|
|
902
1094
|
try {
|
|
903
|
-
await
|
|
1095
|
+
await fs5.access(filePath);
|
|
904
1096
|
} catch {
|
|
905
1097
|
throw new Error("app/copilotkit/page.tsx and src/app/copilotkit/page.tsx not found");
|
|
906
1098
|
}
|
|
907
|
-
let fileContent = await
|
|
1099
|
+
let fileContent = await fs5.readFile(filePath, "utf8");
|
|
908
1100
|
const inputsString = JSON.stringify(inputs);
|
|
909
1101
|
fileContent = fileContent.replace(/\[["']YOUR_INPUTS_HERE["']\]/g, inputsString);
|
|
910
|
-
await
|
|
1102
|
+
await fs5.writeFile(filePath, fileContent, "utf8");
|
|
911
1103
|
spinner.succeed("Successfully added crew inputs to app/copilotkit/page.tsx");
|
|
912
1104
|
} catch (error) {
|
|
913
1105
|
console.error("Error updating crew inputs:", error);
|
|
@@ -928,7 +1120,7 @@ async function getCrewInputs(url, token) {
|
|
|
928
1120
|
}
|
|
929
1121
|
|
|
930
1122
|
// src/commands/init.ts
|
|
931
|
-
import
|
|
1123
|
+
import chalk7 from "chalk";
|
|
932
1124
|
import ora5 from "ora";
|
|
933
1125
|
var CloudInit = class _CloudInit extends BaseCommand {
|
|
934
1126
|
constructor(argv, config, authService = new AuthService()) {
|
|
@@ -948,11 +1140,11 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
948
1140
|
async run() {
|
|
949
1141
|
const { flags } = await this.parse(_CloudInit);
|
|
950
1142
|
try {
|
|
951
|
-
this.log(
|
|
1143
|
+
this.log(chalk7.magenta("\n\u{1FA81} Welcome to CopilotKit"));
|
|
952
1144
|
if (flags.booth) {
|
|
953
|
-
this.log(
|
|
1145
|
+
this.log(chalk7.gray("Thanks for giving CopilotKit a try! Now, let's try to impress you \u{1F4AA}\n"));
|
|
954
1146
|
} else {
|
|
955
|
-
this.log(
|
|
1147
|
+
this.log(chalk7.gray("Let's power up your Next.js project with AI capabilities\n"));
|
|
956
1148
|
}
|
|
957
1149
|
this.validateProjectCompatibility(flags);
|
|
958
1150
|
let userAnswers;
|
|
@@ -962,12 +1154,20 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
962
1154
|
userAnswers = await this.getUserAnswers(flags);
|
|
963
1155
|
}
|
|
964
1156
|
if (userAnswers.mode === "Mastra") {
|
|
965
|
-
this.log(
|
|
966
|
-
\u{1F517} Please go to https://docs.copilotkit.ai/mastra/quickstart
|
|
1157
|
+
this.log(chalk7.magenta(`
|
|
1158
|
+
\u{1F517} Please go to https://docs.copilotkit.ai/mastra/quickstart to get started.`));
|
|
967
1159
|
process.exit(0);
|
|
968
1160
|
} else if (userAnswers.mode === "AG2") {
|
|
969
|
-
this.log(
|
|
970
|
-
\u{1F517} Please go to https://docs.copilotkit.ai/ag2/quickstart
|
|
1161
|
+
this.log(chalk7.magenta(`
|
|
1162
|
+
\u{1F517} Please go to https://docs.copilotkit.ai/ag2/quickstart to get started.`));
|
|
1163
|
+
process.exit(0);
|
|
1164
|
+
} else if (userAnswers.mode === "Agno") {
|
|
1165
|
+
this.log(chalk7.magenta(`
|
|
1166
|
+
\u{1F517} Please go to https://docs.copilotkit.ai/agno/quickstart to get started.`));
|
|
1167
|
+
process.exit(0);
|
|
1168
|
+
} else if (userAnswers.mode === "LlamaIndex") {
|
|
1169
|
+
this.log(chalk7.magenta(`
|
|
1170
|
+
\u{1F517} Please go to https://docs.copilotkit.ai/llamaindex/quickstart to get started.`));
|
|
971
1171
|
process.exit(0);
|
|
972
1172
|
}
|
|
973
1173
|
const needsCloudSetup = userAnswers.useCopilotCloud === "Yes" || userAnswers.mode === "CrewAI";
|
|
@@ -975,16 +1175,27 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
975
1175
|
await scaffoldEnv(flags, userAnswers);
|
|
976
1176
|
await scaffoldShadCN(flags, userAnswers);
|
|
977
1177
|
if (!flags.booth) await scaffoldAgent(userAnswers);
|
|
978
|
-
if (userAnswers.
|
|
1178
|
+
if (userAnswers.crewUrl && userAnswers.crewBearerToken)
|
|
979
1179
|
await addCrewInputs(userAnswers.crewUrl, userAnswers.crewBearerToken);
|
|
1180
|
+
if (userAnswers.setupIDEDocs === "Yes" && userAnswers.selectedIDE !== "skip") {
|
|
1181
|
+
const ideDocsSpinner = ora5({
|
|
1182
|
+
text: "Setting up CopilotKit IDE documentation...",
|
|
1183
|
+
color: "cyan"
|
|
1184
|
+
}).start();
|
|
1185
|
+
try {
|
|
1186
|
+
await handleIDEDocsSetup(userAnswers.selectedIDE, flags.dir, ideDocsSpinner);
|
|
1187
|
+
} catch (error) {
|
|
1188
|
+
ideDocsSpinner.fail("IDE documentation setup failed, but you can configure it manually later");
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
980
1191
|
if (flags.booth) {
|
|
981
1192
|
this.log("\n-----\n");
|
|
982
|
-
this.log(
|
|
983
|
-
this.log(
|
|
984
|
-
this.log(` - Start the Next.js app: ${
|
|
985
|
-
this.log(` - Navigate to ${
|
|
1193
|
+
this.log(chalk7.magenta("\u{1F389} Your CopilotKit setup is complete! \u{1F389}\n"));
|
|
1194
|
+
this.log(chalk7.bold("\n\u{1F680} Next steps:"));
|
|
1195
|
+
this.log(` - Start the Next.js app: ${chalk7.gray("$")} ${chalk7.cyan("npm run dev")}`);
|
|
1196
|
+
this.log(` - Navigate to ${chalk7.blue("http://localhost:3000/copilotkit")}`);
|
|
986
1197
|
this.log(` - Talk to your agent.`);
|
|
987
|
-
this.log(
|
|
1198
|
+
this.log(chalk7.magenta("\nThanks for giving CopilotKit a try! \u{1FA81}\n"));
|
|
988
1199
|
} else {
|
|
989
1200
|
this.finalSummary(userAnswers);
|
|
990
1201
|
}
|
|
@@ -1027,7 +1238,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1027
1238
|
if (Object.keys(initialAnswers).length > 0) {
|
|
1028
1239
|
this.log("\nUsing the following values from provided flags:");
|
|
1029
1240
|
Object.entries(initialAnswers).forEach(([key, value]) => {
|
|
1030
|
-
this.log(` ${
|
|
1241
|
+
this.log(` ${chalk7.green(key)}: ${value}`);
|
|
1031
1242
|
});
|
|
1032
1243
|
this.log("");
|
|
1033
1244
|
}
|
|
@@ -1075,7 +1286,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1075
1286
|
this.log(
|
|
1076
1287
|
"\nCurrently the CLI only supports scaffolding LangGraph Platform agents. Use our quickstart guide to get started:\n"
|
|
1077
1288
|
);
|
|
1078
|
-
this.log(
|
|
1289
|
+
this.log(chalk7.blue("https://docs.copilotkit.ai/coagents/quickstart/langgraph"));
|
|
1079
1290
|
process.exit(0);
|
|
1080
1291
|
}
|
|
1081
1292
|
try {
|
|
@@ -1087,12 +1298,12 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1087
1298
|
const spinner = ora5({ text: "Validation failed...", color: "red" }).start();
|
|
1088
1299
|
if (error.errors) {
|
|
1089
1300
|
const formattedErrors = error.errors.map((err) => `- ${err.path.join(".")}: ${err.message}`).join("\n");
|
|
1090
|
-
spinner.fail(
|
|
1091
|
-
console.error(
|
|
1301
|
+
spinner.fail(chalk7.red("Configuration validation failed:"));
|
|
1302
|
+
console.error(chalk7.red(formattedErrors));
|
|
1092
1303
|
process.exit(1);
|
|
1093
1304
|
}
|
|
1094
|
-
spinner.fail(
|
|
1095
|
-
console.error(
|
|
1305
|
+
spinner.fail(chalk7.red("Unexpected validation error:"));
|
|
1306
|
+
console.error(chalk7.red(error.message || "Unknown error"));
|
|
1096
1307
|
process.exit(1);
|
|
1097
1308
|
}
|
|
1098
1309
|
}
|
|
@@ -1103,11 +1314,11 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1103
1314
|
let selectedProjectId;
|
|
1104
1315
|
if (flags.project) {
|
|
1105
1316
|
if (!availableProjects.some((project) => project.id === flags.project)) {
|
|
1106
|
-
this.log(
|
|
1317
|
+
this.log(chalk7.red(`\u{1F4C1} Project with ID ${flags.project} not found`));
|
|
1107
1318
|
process.exit(1);
|
|
1108
1319
|
}
|
|
1109
1320
|
selectedProjectId = flags.project;
|
|
1110
|
-
this.log(
|
|
1321
|
+
this.log(chalk7.green(`\u{1F4C1} Selected project ${selectedProjectId}`));
|
|
1111
1322
|
} else {
|
|
1112
1323
|
const { projectId } = await inquirer3.prompt([
|
|
1113
1324
|
{
|
|
@@ -1139,12 +1350,12 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1139
1350
|
const updatedConfig = ConfigSchema.parse(sanitizedConfig);
|
|
1140
1351
|
Object.assign(userAnswers, updatedConfig);
|
|
1141
1352
|
} catch (error) {
|
|
1142
|
-
this.log(
|
|
1353
|
+
this.log(chalk7.red(`Failed to update configuration with Copilot Cloud API key: ${error.message}`));
|
|
1143
1354
|
}
|
|
1144
1355
|
if (userAnswers.crewUrl && userAnswers.crewName && userAnswers.crewBearerToken) {
|
|
1145
1356
|
const isFlow = userAnswers.crewType === "Flows";
|
|
1146
1357
|
const crewSpinner = ora5({
|
|
1147
|
-
text:
|
|
1358
|
+
text: chalk7(`\u{1F465} Adding CrewAI ${isFlow ? "Flow" : "Crew"} to Copilot Cloud...`),
|
|
1148
1359
|
color: "cyan"
|
|
1149
1360
|
}).start();
|
|
1150
1361
|
try {
|
|
@@ -1160,22 +1371,22 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1160
1371
|
crewApiBearerToken: userAnswers.crewBearerToken
|
|
1161
1372
|
}
|
|
1162
1373
|
});
|
|
1163
|
-
crewSpinner.succeed(
|
|
1374
|
+
crewSpinner.succeed(chalk7(`\u{1F465} CrewAI ${isFlow ? "Flow" : "Crew"} added to Copilot Cloud`));
|
|
1164
1375
|
} catch (error) {
|
|
1165
|
-
crewSpinner.fail(
|
|
1376
|
+
crewSpinner.fail(chalk7(`\u{1F465} Failed to add CrewAI ${isFlow ? "Flow" : "Crew"} to Copilot Cloud`));
|
|
1166
1377
|
console.error(error);
|
|
1167
1378
|
process.exit(1);
|
|
1168
1379
|
}
|
|
1169
1380
|
}
|
|
1170
1381
|
if (userAnswers.mode === "LangGraph" && userAnswers.useCopilotCloud === "Yes" && userAnswers.alreadyDeployed === "Yes") {
|
|
1171
1382
|
const langGraphSpinner = ora5({
|
|
1172
|
-
text:
|
|
1383
|
+
text: chalk7("\u{1F99C}\u{1F517} Adding LangGraph to Copilot Cloud..."),
|
|
1173
1384
|
color: "cyan"
|
|
1174
1385
|
}).start();
|
|
1175
1386
|
if (userAnswers.langGraphPlatform === "Yes" && userAnswers.langGraphPlatformUrl) {
|
|
1176
1387
|
try {
|
|
1177
1388
|
if (!userAnswers.langSmithApiKey) {
|
|
1178
|
-
langGraphSpinner.fail(
|
|
1389
|
+
langGraphSpinner.fail(chalk7("\u{1F99C}\u{1F517} LangSmith API key not found. Please provide a valid LangSmith API key."));
|
|
1179
1390
|
process.exit(1);
|
|
1180
1391
|
}
|
|
1181
1392
|
await this.trpcClient.createLGCRemoteEndpoint.mutate({
|
|
@@ -1188,9 +1399,9 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1188
1399
|
agents: []
|
|
1189
1400
|
}
|
|
1190
1401
|
});
|
|
1191
|
-
langGraphSpinner.succeed(
|
|
1402
|
+
langGraphSpinner.succeed(chalk7("\u{1F99C}\u{1F517} LangGraph Cloud remote endpoint created"));
|
|
1192
1403
|
} catch (error) {
|
|
1193
|
-
langGraphSpinner.fail(
|
|
1404
|
+
langGraphSpinner.fail(chalk7("\u{1F99C}\u{1F517} Failed to create LangGraph Cloud remote endpoint. Please try again."));
|
|
1194
1405
|
process.exit(1);
|
|
1195
1406
|
}
|
|
1196
1407
|
} else if (userAnswers.langGraphRemoteEndpointURL) {
|
|
@@ -1204,9 +1415,9 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1204
1415
|
// Already sanitized
|
|
1205
1416
|
}
|
|
1206
1417
|
});
|
|
1207
|
-
langGraphSpinner.succeed(
|
|
1418
|
+
langGraphSpinner.succeed(chalk7("\u{1F99C}\u{1F517} LangGraph remote endpoint created"));
|
|
1208
1419
|
} catch (error) {
|
|
1209
|
-
langGraphSpinner.fail(
|
|
1420
|
+
langGraphSpinner.fail(chalk7("\u{1F99C}\u{1F517} Failed to create LangGraph remote endpoint. Please try again."));
|
|
1210
1421
|
process.exit(1);
|
|
1211
1422
|
}
|
|
1212
1423
|
}
|
|
@@ -1215,17 +1426,17 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1215
1426
|
validateProjectCompatibility(flags) {
|
|
1216
1427
|
const spinner = ora5("Checking Next.js project compatibility...").start();
|
|
1217
1428
|
try {
|
|
1218
|
-
const projectPath =
|
|
1219
|
-
if (!
|
|
1429
|
+
const projectPath = path6.resolve(process.cwd(), flags.dir);
|
|
1430
|
+
if (!fs6.existsSync(projectPath)) {
|
|
1220
1431
|
spinner.fail(`Directory ${flags.dir} does not exist`);
|
|
1221
1432
|
throw new Error(`Please provide a valid Next.js project directory.`);
|
|
1222
1433
|
}
|
|
1223
|
-
const packageJsonPath =
|
|
1224
|
-
if (!
|
|
1434
|
+
const packageJsonPath = path6.join(projectPath, "package.json");
|
|
1435
|
+
if (!fs6.existsSync(packageJsonPath)) {
|
|
1225
1436
|
spinner.fail(`No package.json found in ${projectPath}`);
|
|
1226
1437
|
throw new Error(`Please provide a valid Next.js project with a package.json file.`);
|
|
1227
1438
|
}
|
|
1228
|
-
const packageJson = JSON.parse(
|
|
1439
|
+
const packageJson = JSON.parse(fs6.readFileSync(packageJsonPath, "utf8"));
|
|
1229
1440
|
if (!packageJson.dependencies?.next && !packageJson.devDependencies?.next) {
|
|
1230
1441
|
spinner.fail(`Not a Next.js project`);
|
|
1231
1442
|
throw new Error(
|
|
@@ -1236,9 +1447,9 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1236
1447
|
return true;
|
|
1237
1448
|
} catch (error) {
|
|
1238
1449
|
if (!spinner.isSpinning) {
|
|
1239
|
-
this.log(
|
|
1450
|
+
this.log(chalk7.red(error.message));
|
|
1240
1451
|
} else {
|
|
1241
|
-
spinner.fail(
|
|
1452
|
+
spinner.fail(chalk7.red(error.message));
|
|
1242
1453
|
}
|
|
1243
1454
|
process.exit(1);
|
|
1244
1455
|
}
|
|
@@ -1248,9 +1459,9 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1248
1459
|
let agentSetupMessage = "";
|
|
1249
1460
|
if (userAnswers.mode === "CrewAI") {
|
|
1250
1461
|
if (userAnswers.crewType === "Crews") {
|
|
1251
|
-
agentSetupMessage = `Using your Crew from ${
|
|
1462
|
+
agentSetupMessage = `Using your Crew from ${chalk7.cyan(userAnswers.crewUrl || "the provided URL")}.`;
|
|
1252
1463
|
} else if (userAnswers.crewType === "Flows") {
|
|
1253
|
-
agentSetupMessage = `We've scaffolded a ${
|
|
1464
|
+
agentSetupMessage = `We've scaffolded a ${chalk7.cyan("CrewAI Flow")} agent in the ${chalk7.cyan("./agent")} directory.`;
|
|
1254
1465
|
agentDevInstructions = "poetry lock && poetry install && poetry run demo";
|
|
1255
1466
|
}
|
|
1256
1467
|
}
|
|
@@ -1258,11 +1469,11 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1258
1469
|
case "LangGraph":
|
|
1259
1470
|
switch (userAnswers.langGraphAgent) {
|
|
1260
1471
|
case "Python Starter":
|
|
1261
|
-
agentSetupMessage = `We've scaffolded a ${
|
|
1472
|
+
agentSetupMessage = `We've scaffolded a ${chalk7.cyan(userAnswers.langGraphAgent || "LangGraph")} agent in the ${chalk7.cyan("./agent")} directory.`;
|
|
1262
1473
|
agentDevInstructions = "poetry lock && poetry install && npx @langchain/langgraph-cli dev --port 8123";
|
|
1263
1474
|
break;
|
|
1264
1475
|
case "TypeScript Starter":
|
|
1265
|
-
agentSetupMessage = `We've scaffolded a ${
|
|
1476
|
+
agentSetupMessage = `We've scaffolded a ${chalk7.cyan(userAnswers.langGraphAgent || "LangGraph")} agent in the ${chalk7.cyan("./agent")} directory.`;
|
|
1266
1477
|
agentDevInstructions = "npm install && npm run dev";
|
|
1267
1478
|
break;
|
|
1268
1479
|
default:
|
|
@@ -1272,29 +1483,32 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1272
1483
|
case "CrewAI":
|
|
1273
1484
|
switch (userAnswers.crewType) {
|
|
1274
1485
|
case "Crews":
|
|
1275
|
-
agentSetupMessage = `Using your Crew from ${
|
|
1486
|
+
agentSetupMessage = `Using your Crew from ${chalk7.cyan(userAnswers.crewUrl || "the provided URL")}.`;
|
|
1276
1487
|
break;
|
|
1277
1488
|
case "Flows":
|
|
1278
|
-
agentSetupMessage = `We've scaffolded a ${
|
|
1489
|
+
agentSetupMessage = `We've scaffolded a ${chalk7.cyan("CrewAI Flow")} agent in the ${chalk7.cyan("./agent")} directory.`;
|
|
1279
1490
|
break;
|
|
1280
1491
|
}
|
|
1281
1492
|
break;
|
|
1282
1493
|
default:
|
|
1283
1494
|
}
|
|
1284
1495
|
this.log("\n-----\n");
|
|
1285
|
-
this.log(
|
|
1286
|
-
this.log(
|
|
1496
|
+
this.log(chalk7.magenta("\u{1F389} Your CopilotKit setup is complete! \u{1F389}\n"));
|
|
1497
|
+
this.log(chalk7.bold(`\u{1F4CB} Recap`));
|
|
1287
1498
|
this.log(` - CopilotKit has been added to your Next.js app.`);
|
|
1288
1499
|
if (agentSetupMessage) this.log(` - ${agentSetupMessage}`);
|
|
1289
1500
|
if (userAnswers.useCopilotCloud || userAnswers.crewType === "Crews") this.log(` - With Copilot Cloud.`);
|
|
1290
|
-
this.log(
|
|
1291
|
-
this.log(` - Start your Next.js app: ${
|
|
1501
|
+
this.log(chalk7.bold("\n\u{1F680} Next steps:"));
|
|
1502
|
+
this.log(` - Start your Next.js app: ${chalk7.gray("$")} ${chalk7.cyan("npm run dev")}`);
|
|
1292
1503
|
if (agentDevInstructions)
|
|
1293
|
-
this.log(` - Start your agent: ${
|
|
1294
|
-
this.log(` - Navigate to ${
|
|
1504
|
+
this.log(` - Start your agent: ${chalk7.gray("$")} ${chalk7.cyan(`cd agent && ${agentDevInstructions}`)}`);
|
|
1505
|
+
this.log(` - Navigate to ${chalk7.blue("http://localhost:3000/copilotkit")}`);
|
|
1295
1506
|
this.log(` - Talk to your agent.`);
|
|
1296
|
-
|
|
1297
|
-
|
|
1507
|
+
if (userAnswers.setupIDEDocs === "Yes" && userAnswers.selectedIDE !== "skip") {
|
|
1508
|
+
this.log(` - Your IDE now has CopilotKit documentation context for better AI assistance.`);
|
|
1509
|
+
}
|
|
1510
|
+
this.log(` - Read the docs: ${chalk7.blue("https://docs.copilotkit.ai")}`);
|
|
1511
|
+
this.log(chalk7.magenta("\nEnjoy building with CopilotKit \u{1FA81}\n"));
|
|
1298
1512
|
}
|
|
1299
1513
|
};
|
|
1300
1514
|
export {
|