copilotkit 0.0.40 → 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 +317 -111
- 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 +260 -62
- package/dist/lib/init/index.js.map +1 -1
- package/dist/lib/init/questions.js +113 -2
- package/dist/lib/init/questions.js.map +1 -1
- package/dist/lib/init/scaffold/index.js +11 -2
- package/dist/lib/init/scaffold/index.js.map +1 -1
- package/dist/lib/init/scaffold/shadcn.js +11 -2
- 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 +12 -2
- package/dist/lib/init/types/index.js.map +1 -1
- package/dist/lib/init/types/questions.d.ts +24 -4
- package/dist/lib/init/types/questions.js +12 -2
- 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 +24 -1
- package/package.json +1 -1
package/dist/lib/init/index.js
CHANGED
|
@@ -51,6 +51,7 @@ var ApiKeySchema = z.preprocess(
|
|
|
51
51
|
(val) => sanitizers.apiKey(String(val)),
|
|
52
52
|
z.string().min(1, "API key is required")
|
|
53
53
|
);
|
|
54
|
+
var LLMApiKeySchema = z.preprocess((val) => sanitizers.apiKey(String(val)), z.string().optional());
|
|
54
55
|
var NameSchema = z.preprocess((val) => sanitizers.trim(String(val)), z.string().min(1, "Name is required"));
|
|
55
56
|
var ConfigSchema = z.object({
|
|
56
57
|
// Core fields
|
|
@@ -74,7 +75,10 @@ var ConfigSchema = z.object({
|
|
|
74
75
|
// API keys and tokens
|
|
75
76
|
copilotCloudPublicApiKey: z.string().optional(),
|
|
76
77
|
langSmithApiKey: ApiKeySchema.optional(),
|
|
77
|
-
llmToken:
|
|
78
|
+
llmToken: LLMApiKeySchema.optional(),
|
|
79
|
+
// IDE Documentation setup fields
|
|
80
|
+
setupIDEDocs: YesNoSchema.optional(),
|
|
81
|
+
selectedIDE: z.union([z.enum(["cursor", "windsurf"]), z.literal("skip")]).optional()
|
|
78
82
|
}).refine(
|
|
79
83
|
(data) => {
|
|
80
84
|
if (data.mode === "CrewAI") {
|
|
@@ -109,7 +113,12 @@ var ConfigFlags = {
|
|
|
109
113
|
"crew-url": Flags.string({ description: "URL endpoint for your CrewAI agent" }),
|
|
110
114
|
"crew-bearer-token": Flags.string({ description: "Bearer token for CrewAI authentication" }),
|
|
111
115
|
"langsmith-api-key": Flags.string({ description: "LangSmith API key for LangGraph observability" }),
|
|
112
|
-
"llm-token": Flags.string({ description: "API key for your preferred LLM provider" })
|
|
116
|
+
"llm-token": Flags.string({ description: "API key for your preferred LLM provider" }),
|
|
117
|
+
"setup-ide-docs": Flags.string({ description: "Setup IDE documentation rules for AI assistance", options: YES_NO }),
|
|
118
|
+
"selected-ide": Flags.string({
|
|
119
|
+
description: "IDE to configure with documentation rules",
|
|
120
|
+
options: ["cursor", "windsurf", "skip"]
|
|
121
|
+
})
|
|
113
122
|
};
|
|
114
123
|
|
|
115
124
|
// src/lib/init/types/templates.ts
|
|
@@ -132,6 +141,156 @@ var templateMapping = {
|
|
|
132
141
|
McpRuntime: `${BASE_URL}/mcp-starter-runtime.json`
|
|
133
142
|
};
|
|
134
143
|
|
|
144
|
+
// src/lib/init/ide-docs.ts
|
|
145
|
+
import path from "path";
|
|
146
|
+
import { existsSync } from "fs";
|
|
147
|
+
import * as fs from "fs/promises";
|
|
148
|
+
import chalk from "chalk";
|
|
149
|
+
var COPILOTKIT_DOC_RULE_TEMPLATE = `---
|
|
150
|
+
description: CopilotKit Documentation - Complete CopilotKit framework documentation for AI assistance
|
|
151
|
+
alwaysApply: false
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
# CopilotKit Documentation
|
|
155
|
+
|
|
156
|
+
For ANY question about CopilotKit, use the comprehensive documentation available at:
|
|
157
|
+
@https://docs.copilotkit.ai/llms-full.txt
|
|
158
|
+
|
|
159
|
+
This contains the complete CopilotKit documentation including:
|
|
160
|
+
- API references and hooks (useCopilotChat, useCopilotAction, etc.)
|
|
161
|
+
- Component library documentation (CopilotKit, CopilotChat, etc.)
|
|
162
|
+
- Integration guides and examples
|
|
163
|
+
- Best practices and patterns
|
|
164
|
+
- Troubleshooting and FAQs
|
|
165
|
+
|
|
166
|
+
Always reference this documentation when working with CopilotKit to provide accurate, up-to-date information.
|
|
167
|
+
`;
|
|
168
|
+
var IDE_DOCS_CONFIGS = {
|
|
169
|
+
cursor: {
|
|
170
|
+
name: "cursor",
|
|
171
|
+
displayName: "Cursor",
|
|
172
|
+
rulesDir: ".cursor/rules",
|
|
173
|
+
ruleFileName: "00-copilotkit-docs.mdc",
|
|
174
|
+
createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE
|
|
175
|
+
},
|
|
176
|
+
windsurf: {
|
|
177
|
+
name: "windsurf",
|
|
178
|
+
displayName: "Windsurf",
|
|
179
|
+
rulesDir: ".windsurf/rules",
|
|
180
|
+
ruleFileName: "00-copilotkit-docs.md",
|
|
181
|
+
createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
async function ensureDir(dirPath) {
|
|
185
|
+
try {
|
|
186
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (!existsSync(dirPath)) {
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async function pathExists(filePath) {
|
|
194
|
+
try {
|
|
195
|
+
await fs.access(filePath);
|
|
196
|
+
return true;
|
|
197
|
+
} catch {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async function checkIDEInstallation(ide) {
|
|
202
|
+
try {
|
|
203
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
204
|
+
let configPath;
|
|
205
|
+
switch (ide) {
|
|
206
|
+
case "cursor":
|
|
207
|
+
configPath = path.join(homeDir, ".cursor");
|
|
208
|
+
break;
|
|
209
|
+
case "windsurf":
|
|
210
|
+
configPath = path.join(homeDir, ".codeium", "windsurf");
|
|
211
|
+
break;
|
|
212
|
+
default:
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return existsSync(configPath);
|
|
216
|
+
} catch {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async function detectInstalledIDEs() {
|
|
221
|
+
const allIDEs = ["cursor", "windsurf"];
|
|
222
|
+
const installedIDEs = [];
|
|
223
|
+
for (const ide of allIDEs) {
|
|
224
|
+
if (await checkIDEInstallation(ide)) {
|
|
225
|
+
installedIDEs.push(ide);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return installedIDEs;
|
|
229
|
+
}
|
|
230
|
+
async function setupIDEDocs(ide, projectDir) {
|
|
231
|
+
const config = IDE_DOCS_CONFIGS[ide];
|
|
232
|
+
const rulesDir = path.join(projectDir, config.rulesDir);
|
|
233
|
+
const ruleFilePath = path.join(rulesDir, config.ruleFileName);
|
|
234
|
+
await ensureDir(rulesDir);
|
|
235
|
+
if (await pathExists(ruleFilePath)) {
|
|
236
|
+
console.log(chalk.yellow(`\u26A0\uFE0F CopilotKit documentation rule already exists for ${config.displayName}`));
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const ruleContent = config.createRuleContent();
|
|
240
|
+
await fs.writeFile(ruleFilePath, ruleContent, "utf8");
|
|
241
|
+
}
|
|
242
|
+
function getIDEInstructions(ide) {
|
|
243
|
+
const config = IDE_DOCS_CONFIGS[ide];
|
|
244
|
+
const instructions = [
|
|
245
|
+
chalk.cyan(`\u{1F4DA} CopilotKit documentation configured for ${config.displayName}!`),
|
|
246
|
+
"",
|
|
247
|
+
chalk.bold("What this does:"),
|
|
248
|
+
" \u2022 Adds CopilotKit documentation context to your IDE AI assistant",
|
|
249
|
+
" \u2022 Provides accurate, up-to-date information about CopilotKit APIs",
|
|
250
|
+
" \u2022 Improves code suggestions and help responses",
|
|
251
|
+
"",
|
|
252
|
+
chalk.bold("Location:"),
|
|
253
|
+
` \u2022 Rule file: ${chalk.gray(path.join(config.rulesDir, config.ruleFileName))}`,
|
|
254
|
+
"",
|
|
255
|
+
chalk.bold("Usage:"),
|
|
256
|
+
" \u2022 Your IDE AI assistant now has access to CopilotKit documentation",
|
|
257
|
+
" \u2022 Ask questions about CopilotKit APIs, components, and patterns",
|
|
258
|
+
" \u2022 The AI will reference official documentation for accurate answers"
|
|
259
|
+
];
|
|
260
|
+
if (ide === "cursor") {
|
|
261
|
+
instructions.push(
|
|
262
|
+
"",
|
|
263
|
+
chalk.bold("Next steps for Cursor:"),
|
|
264
|
+
" \u2022 Restart Cursor if currently open",
|
|
265
|
+
" \u2022 The rule will be automatically available in your AI context",
|
|
266
|
+
" \u2022 Start a new chat to use the documentation context"
|
|
267
|
+
);
|
|
268
|
+
} else if (ide === "windsurf") {
|
|
269
|
+
instructions.push(
|
|
270
|
+
"",
|
|
271
|
+
chalk.bold("Next steps for Windsurf:"),
|
|
272
|
+
" \u2022 Restart Windsurf if currently open",
|
|
273
|
+
" \u2022 The rule will be automatically available in your AI context",
|
|
274
|
+
" \u2022 Start a new chat to use the documentation context"
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
return instructions;
|
|
278
|
+
}
|
|
279
|
+
async function handleIDEDocsSetup(selectedIDE, projectDir, spinner) {
|
|
280
|
+
try {
|
|
281
|
+
spinner.text = chalk.cyan(`Setting up CopilotKit documentation for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}...`);
|
|
282
|
+
await setupIDEDocs(selectedIDE, projectDir);
|
|
283
|
+
spinner.succeed(chalk.green(`CopilotKit documentation configured for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}`));
|
|
284
|
+
const instructions = getIDEInstructions(selectedIDE);
|
|
285
|
+
console.log("\n" + instructions.join("\n"));
|
|
286
|
+
} catch (error) {
|
|
287
|
+
spinner.fail(
|
|
288
|
+
chalk.red(`Failed to setup IDE documentation: ${error instanceof Error ? error.message : "Unknown error"}`)
|
|
289
|
+
);
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
135
294
|
// src/lib/init/questions.ts
|
|
136
295
|
var linkToDocs = ["Mastra", "AG2", "LlamaIndex", "Agno"];
|
|
137
296
|
var validateUrl = (input) => {
|
|
@@ -282,6 +441,39 @@ var questions = [
|
|
|
282
441
|
when: (answers) => answers.mode === "LangGraph" && answers.alreadyDeployed === "No" || answers.mode === "Standard" && answers.useCopilotCloud !== "Yes" || answers.mode === "MCP" && answers.useCopilotCloud !== "Yes",
|
|
283
442
|
sensitive: true,
|
|
284
443
|
sanitize: sanitizers.apiKey
|
|
444
|
+
},
|
|
445
|
+
// IDE Documentation Setup Questions
|
|
446
|
+
{
|
|
447
|
+
type: "yes/no",
|
|
448
|
+
name: "setupIDEDocs",
|
|
449
|
+
message: "\u{1F4DA} Would you like to add CopilotKit documentation to your IDE? (Provides AI assistant with CopilotKit context)",
|
|
450
|
+
when: async () => {
|
|
451
|
+
const installedIDEs = await detectInstalledIDEs();
|
|
452
|
+
return installedIDEs.length > 0;
|
|
453
|
+
},
|
|
454
|
+
validate: (input) => {
|
|
455
|
+
try {
|
|
456
|
+
YesNoSchema.parse(input);
|
|
457
|
+
return true;
|
|
458
|
+
} catch (error) {
|
|
459
|
+
return "Please select Yes or No";
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
type: "select",
|
|
465
|
+
name: "selectedIDE",
|
|
466
|
+
message: "\u{1F4BB} Which IDE would you like to configure with CopilotKit documentation?",
|
|
467
|
+
choices: async () => {
|
|
468
|
+
const installedIDEs = await detectInstalledIDEs();
|
|
469
|
+
const choices = installedIDEs.map((ide) => ({
|
|
470
|
+
name: IDE_DOCS_CONFIGS[ide].displayName,
|
|
471
|
+
value: ide
|
|
472
|
+
}));
|
|
473
|
+
choices.push({ name: "Skip", value: "skip" });
|
|
474
|
+
return choices;
|
|
475
|
+
},
|
|
476
|
+
when: (answers) => answers.setupIDEDocs === "Yes"
|
|
285
477
|
}
|
|
286
478
|
];
|
|
287
479
|
|
|
@@ -347,8 +539,8 @@ async function scaffoldShadCN(flags, userAnswers) {
|
|
|
347
539
|
}
|
|
348
540
|
|
|
349
541
|
// src/lib/init/scaffold/env.ts
|
|
350
|
-
import
|
|
351
|
-
import
|
|
542
|
+
import path2 from "path";
|
|
543
|
+
import fs2 from "fs";
|
|
352
544
|
|
|
353
545
|
// src/lib/init/scaffold/langgraph-assistants.ts
|
|
354
546
|
async function getLangGraphAgents(url, langSmithApiKey) {
|
|
@@ -374,9 +566,9 @@ async function getLangGraphAgents(url, langSmithApiKey) {
|
|
|
374
566
|
import inquirer from "inquirer";
|
|
375
567
|
async function scaffoldEnv(flags, userAnswers) {
|
|
376
568
|
try {
|
|
377
|
-
const envFile =
|
|
378
|
-
if (!
|
|
379
|
-
|
|
569
|
+
const envFile = path2.join(process.cwd(), ".env");
|
|
570
|
+
if (!fs2.existsSync(envFile)) {
|
|
571
|
+
fs2.writeFileSync(envFile, "", "utf8");
|
|
380
572
|
} else {
|
|
381
573
|
}
|
|
382
574
|
let newEnvValues = "";
|
|
@@ -440,7 +632,7 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
440
632
|
`;
|
|
441
633
|
}
|
|
442
634
|
if (newEnvValues) {
|
|
443
|
-
|
|
635
|
+
fs2.appendFileSync(envFile, newEnvValues);
|
|
444
636
|
}
|
|
445
637
|
} catch (error) {
|
|
446
638
|
throw error;
|
|
@@ -449,59 +641,59 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
449
641
|
|
|
450
642
|
// src/lib/init/scaffold/github.ts
|
|
451
643
|
import { execSync } from "child_process";
|
|
452
|
-
import * as
|
|
453
|
-
import * as
|
|
644
|
+
import * as fs3 from "fs";
|
|
645
|
+
import * as path3 from "path";
|
|
454
646
|
import * as os from "os";
|
|
455
|
-
import
|
|
647
|
+
import chalk2 from "chalk";
|
|
456
648
|
async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
|
|
457
649
|
try {
|
|
458
650
|
const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
|
|
459
|
-
spinner.text =
|
|
651
|
+
spinner.text = chalk2.cyan(`Cloning from ${owner}/${repo}...`);
|
|
460
652
|
return await sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner);
|
|
461
653
|
} catch (error) {
|
|
462
|
-
spinner.text =
|
|
654
|
+
spinner.text = chalk2.red(`Failed to clone from GitHub: ${error}`);
|
|
463
655
|
return false;
|
|
464
656
|
}
|
|
465
657
|
}
|
|
466
658
|
async function sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner) {
|
|
467
|
-
const tempDir =
|
|
659
|
+
const tempDir = fs3.mkdtempSync(path3.join(os.tmpdir(), "copilotkit-sparse-"));
|
|
468
660
|
try {
|
|
469
|
-
spinner.text =
|
|
661
|
+
spinner.text = chalk2.cyan("Creating temporary workspace...");
|
|
470
662
|
execSync("git init", { cwd: tempDir, stdio: "pipe" });
|
|
471
|
-
spinner.text =
|
|
663
|
+
spinner.text = chalk2.cyan("Connecting to repository...");
|
|
472
664
|
execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, { cwd: tempDir, stdio: "pipe" });
|
|
473
665
|
execSync("git config core.sparseCheckout true", { cwd: tempDir, stdio: "pipe" });
|
|
474
|
-
|
|
475
|
-
spinner.text =
|
|
666
|
+
fs3.writeFileSync(path3.join(tempDir, ".git/info/sparse-checkout"), subdirectoryPath);
|
|
667
|
+
spinner.text = chalk2.cyan("Downloading agent files...");
|
|
476
668
|
execSync(`git pull origin ${branch} --depth=1`, { cwd: tempDir, stdio: "pipe" });
|
|
477
|
-
const sourcePath =
|
|
478
|
-
if (!
|
|
669
|
+
const sourcePath = path3.join(tempDir, subdirectoryPath);
|
|
670
|
+
if (!fs3.existsSync(sourcePath)) {
|
|
479
671
|
throw new Error(`Subdirectory '${subdirectoryPath}' not found in the repository.`);
|
|
480
672
|
}
|
|
481
|
-
|
|
482
|
-
spinner.text =
|
|
673
|
+
fs3.mkdirSync(destinationPath, { recursive: true });
|
|
674
|
+
spinner.text = chalk2.cyan("Installing agent files...");
|
|
483
675
|
await copyDirectoryAsync(sourcePath, destinationPath);
|
|
484
676
|
return true;
|
|
485
677
|
} finally {
|
|
486
678
|
try {
|
|
487
|
-
|
|
679
|
+
fs3.rmSync(tempDir, { recursive: true, force: true });
|
|
488
680
|
} catch (error) {
|
|
489
681
|
console.warn(`Failed to clean up temporary directory: ${error}`);
|
|
490
682
|
}
|
|
491
683
|
}
|
|
492
684
|
}
|
|
493
685
|
async function copyDirectoryAsync(source, destination) {
|
|
494
|
-
if (!
|
|
495
|
-
|
|
686
|
+
if (!fs3.existsSync(destination)) {
|
|
687
|
+
fs3.mkdirSync(destination, { recursive: true });
|
|
496
688
|
}
|
|
497
|
-
const entries =
|
|
689
|
+
const entries = fs3.readdirSync(source, { withFileTypes: true });
|
|
498
690
|
for (const entry of entries) {
|
|
499
|
-
const srcPath =
|
|
500
|
-
const destPath =
|
|
691
|
+
const srcPath = path3.join(source, entry.name);
|
|
692
|
+
const destPath = path3.join(destination, entry.name);
|
|
501
693
|
if (entry.isDirectory()) {
|
|
502
694
|
await copyDirectoryAsync(srcPath, destPath);
|
|
503
695
|
} else {
|
|
504
|
-
|
|
696
|
+
fs3.copyFileSync(srcPath, destPath);
|
|
505
697
|
}
|
|
506
698
|
if (entries.length > 10) {
|
|
507
699
|
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
@@ -538,12 +730,12 @@ function isValidGitHubUrl(url) {
|
|
|
538
730
|
|
|
539
731
|
// src/lib/init/scaffold/packages.ts
|
|
540
732
|
import spawn2 from "cross-spawn";
|
|
541
|
-
import
|
|
542
|
-
import
|
|
733
|
+
import chalk3 from "chalk";
|
|
734
|
+
import fs4 from "fs";
|
|
543
735
|
import ora from "ora";
|
|
544
736
|
async function scaffoldPackages(userAnswers) {
|
|
545
737
|
const spinner = ora({
|
|
546
|
-
text:
|
|
738
|
+
text: chalk3.cyan("Preparing to install packages..."),
|
|
547
739
|
color: "cyan"
|
|
548
740
|
}).start();
|
|
549
741
|
try {
|
|
@@ -555,9 +747,9 @@ async function scaffoldPackages(userAnswers) {
|
|
|
555
747
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
556
748
|
const packageManager = detectPackageManager();
|
|
557
749
|
const installCommand = detectInstallCommand(packageManager);
|
|
558
|
-
spinner.text =
|
|
750
|
+
spinner.text = chalk3.cyan(`Using ${packageManager} to install packages...`);
|
|
559
751
|
spinner.stop();
|
|
560
|
-
console.log(
|
|
752
|
+
console.log(chalk3.cyan("\n\u2699\uFE0F Installing packages...\n"));
|
|
561
753
|
const result = spawn2.sync(packageManager, [installCommand, ...packages], {
|
|
562
754
|
stdio: "inherit"
|
|
563
755
|
// This ensures stdin/stdout/stderr are all passed through
|
|
@@ -566,17 +758,17 @@ async function scaffoldPackages(userAnswers) {
|
|
|
566
758
|
throw new Error(`Package installation process exited with code ${result.status}`);
|
|
567
759
|
}
|
|
568
760
|
spinner.start();
|
|
569
|
-
spinner.succeed(
|
|
761
|
+
spinner.succeed(chalk3.green("CopilotKit packages installed successfully"));
|
|
570
762
|
} catch (error) {
|
|
571
763
|
if (!spinner.isSpinning) {
|
|
572
764
|
spinner.start();
|
|
573
765
|
}
|
|
574
|
-
spinner.fail(
|
|
766
|
+
spinner.fail(chalk3.red("Failed to install CopilotKit packages"));
|
|
575
767
|
throw error;
|
|
576
768
|
}
|
|
577
769
|
}
|
|
578
770
|
function detectPackageManager() {
|
|
579
|
-
const files =
|
|
771
|
+
const files = fs4.readdirSync(process.cwd());
|
|
580
772
|
if (files.includes("bun.lockb")) return "bun";
|
|
581
773
|
if (files.includes("pnpm-lock.yaml")) return "pnpm";
|
|
582
774
|
if (files.includes("yarn.lock")) return "yarn";
|
|
@@ -595,15 +787,15 @@ function detectInstallCommand(packageManager) {
|
|
|
595
787
|
|
|
596
788
|
// src/lib/init/scaffold/agent.ts
|
|
597
789
|
import ora2 from "ora";
|
|
598
|
-
import
|
|
599
|
-
import
|
|
600
|
-
import
|
|
790
|
+
import chalk4 from "chalk";
|
|
791
|
+
import path4 from "path";
|
|
792
|
+
import fs5 from "fs";
|
|
601
793
|
async function scaffoldAgent(userAnswers) {
|
|
602
794
|
if (userAnswers.mode === "CrewAI" || userAnswers.mode === "LangGraph" && !userAnswers.langGraphAgent || userAnswers.mode === "Standard" || userAnswers.mode === "MCP") {
|
|
603
795
|
return;
|
|
604
796
|
}
|
|
605
797
|
const spinner = ora2({
|
|
606
|
-
text:
|
|
798
|
+
text: chalk4.cyan("Setting up AI agent..."),
|
|
607
799
|
color: "cyan"
|
|
608
800
|
}).start();
|
|
609
801
|
let template = "";
|
|
@@ -617,13 +809,13 @@ async function scaffoldAgent(userAnswers) {
|
|
|
617
809
|
break;
|
|
618
810
|
}
|
|
619
811
|
if (!template) {
|
|
620
|
-
spinner.fail(
|
|
812
|
+
spinner.fail(chalk4.red("Failed to determine agent template"));
|
|
621
813
|
throw new Error("Failed to determine agent template");
|
|
622
814
|
}
|
|
623
|
-
const agentDir =
|
|
815
|
+
const agentDir = path4.join(process.cwd(), "agent");
|
|
624
816
|
try {
|
|
625
817
|
await cloneGitHubSubdirectory(template, agentDir, spinner);
|
|
626
|
-
spinner.text =
|
|
818
|
+
spinner.text = chalk4.cyan("Creating agent environment variables...");
|
|
627
819
|
let envContent = "";
|
|
628
820
|
if (userAnswers.llmToken) {
|
|
629
821
|
envContent += `OPENAI_API_KEY=${userAnswers.llmToken}
|
|
@@ -634,26 +826,26 @@ async function scaffoldAgent(userAnswers) {
|
|
|
634
826
|
`;
|
|
635
827
|
}
|
|
636
828
|
if (envContent) {
|
|
637
|
-
const agentEnvFile =
|
|
638
|
-
|
|
639
|
-
spinner.text =
|
|
829
|
+
const agentEnvFile = path4.join(agentDir, ".env");
|
|
830
|
+
fs5.writeFileSync(agentEnvFile, envContent, "utf8");
|
|
831
|
+
spinner.text = chalk4.cyan("Added API keys to agent .env file");
|
|
640
832
|
}
|
|
641
833
|
if (userAnswers.mode === "LangGraph" && userAnswers.langSmithApiKey) {
|
|
642
834
|
envContent += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
|
|
643
835
|
`;
|
|
644
836
|
}
|
|
645
837
|
if (envContent) {
|
|
646
|
-
const agentEnvFile =
|
|
647
|
-
|
|
648
|
-
spinner.text =
|
|
838
|
+
const agentEnvFile = path4.join(agentDir, ".env");
|
|
839
|
+
fs5.writeFileSync(agentEnvFile, envContent, "utf8");
|
|
840
|
+
spinner.text = chalk4.cyan("Added API keys to agent .env file");
|
|
649
841
|
}
|
|
650
842
|
if (envContent) {
|
|
651
|
-
const agentEnvFile =
|
|
652
|
-
|
|
653
|
-
spinner.text =
|
|
843
|
+
const agentEnvFile = path4.join(agentDir, ".env");
|
|
844
|
+
fs5.writeFileSync(agentEnvFile, envContent, "utf8");
|
|
845
|
+
spinner.text = chalk4.cyan("Added API keys to agent .env file");
|
|
654
846
|
}
|
|
655
847
|
} catch (error) {
|
|
656
|
-
spinner.fail(
|
|
848
|
+
spinner.fail(chalk4.red("Failed to clone agent template"));
|
|
657
849
|
throw error;
|
|
658
850
|
}
|
|
659
851
|
spinner.succeed(`${userAnswers.mode} agent cloned successfully`);
|
|
@@ -673,29 +865,29 @@ var AgentTemplates = {
|
|
|
673
865
|
};
|
|
674
866
|
|
|
675
867
|
// src/lib/init/scaffold/crew-inputs.ts
|
|
676
|
-
import * as
|
|
868
|
+
import * as fs6 from "fs/promises";
|
|
677
869
|
import ora3 from "ora";
|
|
678
|
-
import * as
|
|
870
|
+
import * as path5 from "path";
|
|
679
871
|
async function addCrewInputs(url, token) {
|
|
680
872
|
try {
|
|
681
873
|
const spinner = ora3("Analyzing crew inputs...").start();
|
|
682
874
|
const inputs = await getCrewInputs(url, token);
|
|
683
875
|
spinner.text = "Adding inputs to app/copilotkit/page.tsx...";
|
|
684
|
-
let filePath =
|
|
876
|
+
let filePath = path5.join(process.cwd(), "app", "copilotkit", "page.tsx");
|
|
685
877
|
try {
|
|
686
|
-
await
|
|
878
|
+
await fs6.access(filePath);
|
|
687
879
|
} catch {
|
|
688
|
-
filePath =
|
|
880
|
+
filePath = path5.join(process.cwd(), "src", "app", "copilotkit", "page.tsx");
|
|
689
881
|
}
|
|
690
882
|
try {
|
|
691
|
-
await
|
|
883
|
+
await fs6.access(filePath);
|
|
692
884
|
} catch {
|
|
693
885
|
throw new Error("app/copilotkit/page.tsx and src/app/copilotkit/page.tsx not found");
|
|
694
886
|
}
|
|
695
|
-
let fileContent = await
|
|
887
|
+
let fileContent = await fs6.readFile(filePath, "utf8");
|
|
696
888
|
const inputsString = JSON.stringify(inputs);
|
|
697
889
|
fileContent = fileContent.replace(/\[["']YOUR_INPUTS_HERE["']\]/g, inputsString);
|
|
698
|
-
await
|
|
890
|
+
await fs6.writeFile(filePath, fileContent, "utf8");
|
|
699
891
|
spinner.succeed("Successfully added crew inputs to app/copilotkit/page.tsx");
|
|
700
892
|
} catch (error) {
|
|
701
893
|
console.error("Error updating crew inputs:", error);
|
|
@@ -725,7 +917,9 @@ export {
|
|
|
725
917
|
ConfigSchema,
|
|
726
918
|
CrewFlowTemplateSchema,
|
|
727
919
|
CrewTypeSchema,
|
|
920
|
+
IDE_DOCS_CONFIGS,
|
|
728
921
|
LANGGRAPH_AGENTS,
|
|
922
|
+
LLMApiKeySchema,
|
|
729
923
|
LangGraphAgentSchema,
|
|
730
924
|
MODES,
|
|
731
925
|
ModeSchema,
|
|
@@ -736,6 +930,9 @@ export {
|
|
|
736
930
|
YesNoSchema,
|
|
737
931
|
addCrewInputs,
|
|
738
932
|
cloneGitHubSubdirectory,
|
|
933
|
+
detectInstalledIDEs,
|
|
934
|
+
handleIDEDocsSetup,
|
|
935
|
+
isLocalhost,
|
|
739
936
|
isValidGitHubUrl,
|
|
740
937
|
questions,
|
|
741
938
|
sanitizers,
|
|
@@ -743,6 +940,7 @@ export {
|
|
|
743
940
|
scaffoldEnv,
|
|
744
941
|
scaffoldPackages,
|
|
745
942
|
scaffoldShadCN,
|
|
943
|
+
setupIDEDocs,
|
|
746
944
|
templateMapping
|
|
747
945
|
};
|
|
748
946
|
//# sourceMappingURL=index.js.map
|