copilotkit 0.0.57 → 0.0.59

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.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/dist/commands/base-command.js +9 -6
  3. package/dist/commands/base-command.js.map +1 -1
  4. package/dist/commands/create.d.ts +1 -1
  5. package/dist/commands/create.js +234 -59
  6. package/dist/commands/create.js.map +1 -1
  7. package/dist/commands/dev.js +94 -35
  8. package/dist/commands/dev.js.map +1 -1
  9. package/dist/commands/init.d.ts +0 -20
  10. package/dist/commands/init.js +243 -209
  11. package/dist/commands/init.js.map +1 -1
  12. package/dist/commands/login.js +44 -20
  13. package/dist/commands/login.js.map +1 -1
  14. package/dist/commands/logout.js +44 -20
  15. package/dist/commands/logout.js.map +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/lib/init/ide-docs.d.ts +1 -1
  18. package/dist/lib/init/ide-docs.js +19 -5
  19. package/dist/lib/init/ide-docs.js.map +1 -1
  20. package/dist/lib/init/index.js +171 -67
  21. package/dist/lib/init/index.js.map +1 -1
  22. package/dist/lib/init/questions.d.ts +1 -1
  23. package/dist/lib/init/questions.js +77 -18
  24. package/dist/lib/init/questions.js.map +1 -1
  25. package/dist/lib/init/scaffold/agent.js +30 -23
  26. package/dist/lib/init/scaffold/agent.js.map +1 -1
  27. package/dist/lib/init/scaffold/crew-inputs.js +17 -4
  28. package/dist/lib/init/scaffold/crew-inputs.js.map +1 -1
  29. package/dist/lib/init/scaffold/env.js +14 -11
  30. package/dist/lib/init/scaffold/env.js.map +1 -1
  31. package/dist/lib/init/scaffold/github.js +27 -6
  32. package/dist/lib/init/scaffold/github.js.map +1 -1
  33. package/dist/lib/init/scaffold/index.js +152 -62
  34. package/dist/lib/init/scaffold/index.js.map +1 -1
  35. package/dist/lib/init/scaffold/langgraph-assistants.js +14 -11
  36. package/dist/lib/init/scaffold/langgraph-assistants.js.map +1 -1
  37. package/dist/lib/init/scaffold/packages.js +3 -1
  38. package/dist/lib/init/scaffold/packages.js.map +1 -1
  39. package/dist/lib/init/scaffold/shadcn.js +88 -23
  40. package/dist/lib/init/scaffold/shadcn.js.map +1 -1
  41. package/dist/lib/init/types/index.js +77 -18
  42. package/dist/lib/init/types/index.js.map +1 -1
  43. package/dist/lib/init/types/questions.d.ts +19 -19
  44. package/dist/lib/init/types/questions.js +73 -17
  45. package/dist/lib/init/types/questions.js.map +1 -1
  46. package/dist/lib/init/types/templates.d.ts +2 -2
  47. package/dist/lib/init/types/templates.js +4 -1
  48. package/dist/lib/init/types/templates.js.map +1 -1
  49. package/dist/lib/init/utils.js.map +1 -1
  50. package/dist/services/analytics.service.d.ts +1 -1
  51. package/dist/services/analytics.service.js +4 -1
  52. package/dist/services/analytics.service.js.map +1 -1
  53. package/dist/services/auth.service.d.ts +1 -1
  54. package/dist/services/auth.service.js +35 -14
  55. package/dist/services/auth.service.js.map +1 -1
  56. package/dist/services/events.d.ts +33 -33
  57. package/dist/services/tunnel.service.js.map +1 -1
  58. package/dist/utils/detect-endpoint-type.utils.d.ts +1 -1
  59. package/dist/utils/detect-endpoint-type.utils.js +11 -4
  60. package/dist/utils/detect-endpoint-type.utils.js.map +1 -1
  61. package/dist/utils/trpc.js.map +1 -1
  62. package/dist/utils/version.d.ts +1 -1
  63. package/dist/utils/version.js +1 -1
  64. package/dist/utils/version.js.map +1 -1
  65. package/oclif.manifest.json +6 -163
  66. package/package.json +8 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/logout.ts","../../src/services/auth.service.ts","../../src/utils/trpc.ts","../../src/services/analytics.service.ts","../../src/commands/base-command.ts","../../src/utils/version.ts"],"sourcesContent":["import {Config} from '@oclif/core'\nimport chalk from 'chalk'\nimport ora from 'ora'\n\nimport {AuthService} from '../services/auth.service.js'\nimport {BaseCommand} from './base-command.js'\n\nexport default class CloudLogout extends BaseCommand {\n static override description = 'Logout from Copilot Cloud'\n\n static override examples = ['<%= config.bin %> logout']\n\n constructor(\n argv: string[],\n config: Config,\n private authService = new AuthService(),\n ) {\n super(argv, config)\n }\n\n public async run(): Promise<void> {\n await this.parse(CloudLogout)\n this.log('Logging out...\\n')\n await this.authService.logout(this)\n this.log(chalk.green('Successfully logged out!'))\n }\n}\n","// @ts-ignore\nimport Conf from 'conf'\nimport cors from 'cors'\nimport express from 'express'\nimport crypto from 'node:crypto'\nimport open from 'open'\nimport getPort from 'get-port'\nimport ora from 'ora'\nimport chalk from 'chalk'\nimport inquirer from 'inquirer'\nimport {Command} from '@oclif/core'\nimport {createTRPCClient} from '../utils/trpc.js'\nimport {AnalyticsService} from '../services/analytics.service.js'\nimport {BaseCommand} from '../commands/base-command.js'\n\ninterface LoginResponse {\n cliToken: string\n user: {\n email: string\n id: string\n }\n organization: {\n id: string\n }\n}\n\nexport class AuthService {\n private readonly config = new Conf({projectName: 'CopilotKitCLI'})\n private readonly COPILOT_CLOUD_BASE_URL = process.env.COPILOT_CLOUD_BASE_URL || 'https://cloud.copilotkit.ai'\n\n getToken(): string | undefined {\n return this.config.get('cliToken') as string | undefined\n }\n\n getCLIToken(): string | undefined {\n const cliToken = this.config.get('cliToken') as string | undefined\n return cliToken\n }\n\n async logout(cmd: BaseCommand): Promise<void> {\n this.config.delete('cliToken')\n }\n\n async requireLogin(cmd: Command, context?: 'cloud-features' | 'general'): Promise<LoginResponse> {\n let cliToken = this.getCLIToken()\n // Check authentication\n if (!cliToken) {\n try {\n let shouldLogin = true\n\n // For cloud features, automatically proceed with login\n // For general usage, ask for confirmation\n if (context !== 'cloud-features') {\n const response = await inquirer.prompt([\n {\n name: 'shouldLogin',\n type: 'confirm',\n message: '🪁 You are not yet authenticated. Authenticate with Copilot Cloud? (press Enter to confirm)',\n default: true,\n },\n ])\n shouldLogin = response.shouldLogin\n }\n\n if (shouldLogin) {\n // Show different message for cloud features vs general usage\n if (context === 'cloud-features') {\n cmd.log(chalk.cyan('\\nšŸš€ Setting up Copilot Cloud authentication...\\n'))\n }\n const loginResult = await this.login({exitAfterLogin: false})\n cliToken = loginResult.cliToken\n return loginResult\n } else {\n cmd.error('Authentication required to proceed.')\n }\n } catch (error) {\n if (error instanceof Error && error.name === 'ExitPromptError') {\n cmd.error(chalk.yellow('\\nAuthentication cancelled'))\n }\n\n throw error\n }\n }\n\n let me\n\n const trpcClient = createTRPCClient(cliToken)\n try {\n me = await trpcClient.me.query()\n } catch (error) {\n // Token is invalid/expired, trigger new login\n cmd.log(chalk.yellow('Your authentication has expired. Re-authenticating...'))\n try {\n const loginResult = await this.login({exitAfterLogin: false})\n return loginResult\n } catch (loginError) {\n cmd.log(chalk.red('Could not authenticate with Copilot Cloud. Please run: npx copilotkit@latest login'))\n process.exit(1)\n }\n }\n\n if (!me.organization || !me.user) {\n cmd.error('Authentication required to proceed.')\n }\n\n return {cliToken, user: me.user, organization: me.organization}\n }\n\n async login({exitAfterLogin}: {exitAfterLogin?: boolean} = {exitAfterLogin: true}): Promise<LoginResponse> {\n const spinner = ora('🪁 Opening browser for authentication...').start()\n let analytics: AnalyticsService\n analytics = new AnalyticsService()\n\n const app = express()\n app.use(cors())\n app.use(express.urlencoded({extended: true}))\n app.use(express.json())\n\n const port = await getPort()\n const state = crypto.randomBytes(16).toString('hex')\n\n return new Promise(async (resolve) => {\n const server = app.listen(port, () => {})\n\n await analytics.track({\n event: 'cli.login.initiated',\n properties: {},\n })\n\n spinner.text = '🪁 Waiting for browser authentication to complete...'\n\n app.post('/callback', async (req, res) => {\n const {cliToken, user, organization} = req.body\n\n analytics = new AnalyticsService({userId: user.id, organizationId: organization.id, email: user.email})\n await analytics.track({\n event: 'cli.login.success',\n properties: {\n organizationId: organization.id,\n userId: user.id,\n email: user.email,\n },\n })\n\n if (state !== req.query.state) {\n res.status(401).json({message: 'Invalid state'})\n spinner.fail('Invalid state')\n return\n }\n\n this.config.set('cliToken', cliToken)\n res.status(200).json({message: 'Callback called'})\n spinner.succeed(`🪁 Successfully logged in as ${chalk.hex('#7553fc')(user.email)}`)\n if (exitAfterLogin) {\n process.exit(0)\n } else {\n server.close()\n resolve({cliToken, user, organization})\n }\n })\n\n open(`${this.COPILOT_CLOUD_BASE_URL}/cli-auth?callbackUrl=http://localhost:${port}/callback&state=${state}`)\n })\n }\n}\n","import {createTRPCClient as trpcClient, httpBatchLink} from '@trpc/client'\nimport superjson from 'superjson'\n\nexport const COPILOT_CLOUD_BASE_URL = process.env.COPILOT_CLOUD_BASE_URL || 'https://cloud.copilotkit.ai'\n\nexport function createTRPCClient(cliToken: string): any {\n return trpcClient({\n links: [\n httpBatchLink({\n url: `${COPILOT_CLOUD_BASE_URL}/api/trpc-cli`,\n transformer: superjson,\n headers: () => {\n return {\n 'x-trpc-source': 'cli',\n 'x-cli-token': cliToken,\n }\n },\n }),\n ],\n })\n}\n","import {Analytics} from '@segment/analytics-node'\nimport {PostHog} from 'posthog-node'\nimport {AnalyticsEvents} from './events.js'\nimport Conf from 'conf'\n\nexport class AnalyticsService {\n private segment: Analytics | undefined\n private posthog: PostHog | undefined\n private globalProperties: Record<string, any> = {}\n private userId: string | undefined\n private email: string | undefined\n private organizationId: string | undefined\n private config = new Conf({projectName: 'CopilotKitCLI'})\n\n constructor(\n private readonly authData?: {\n userId: string\n email: string\n organizationId: string\n },\n ) {\n if (process.env.SEGMENT_DISABLED === 'true') {\n return\n }\n\n const segmentWriteKey = process.env.SEGMENT_WRITE_KEY || '9Pv6QyExYef2P4hPz4gks6QAvNMi2AOf'\n\n this.globalProperties = {\n service: 'cli',\n }\n\n if (this.authData?.userId) {\n this.userId = this.authData.userId\n }\n\n if (this.authData?.email) {\n this.email = this.authData.email\n this.globalProperties.email = this.authData.email\n }\n\n if (this.authData?.organizationId) {\n this.organizationId = this.authData.organizationId\n }\n\n this.segment = new Analytics({\n writeKey: segmentWriteKey,\n disable: process.env.SEGMENT_DISABLE === 'true',\n })\n\n // Initialize PostHog for feature flags\n if (process.env.POSTHOG_DISABLED !== 'true') {\n const posthogKey = process.env.POSTHOG_KEY || 'phc_XZdymVYjrph9Mi0xZYGNyCKexxgblXRR1jMENCtdz5Q' // Default key\n const posthogHost = process.env.POSTHOG_HOST || 'https://eu.i.posthog.com'\n\n this.posthog = new PostHog(posthogKey, {\n host: posthogHost,\n })\n }\n\n const config = new Conf({projectName: 'CopilotKitCLI'})\n if (!config.get('anonymousId')) {\n config.set('anonymousId', crypto.randomUUID())\n }\n }\n\n private getAnonymousId(): string {\n const anonymousId = this.config.get('anonymousId')\n if (!anonymousId) {\n const anonymousId = crypto.randomUUID()\n this.config.set('anonymousId', anonymousId)\n return anonymousId\n }\n\n return anonymousId as string\n }\n\n public track<K extends keyof AnalyticsEvents>(\n event: Omit<Parameters<Analytics['track']>[0], 'userId'> & {\n event: K\n properties: AnalyticsEvents[K]\n },\n ): Promise<void> {\n if (!this.segment) {\n return Promise.resolve()\n }\n\n const payload = {\n userId: this.userId ? this.userId : undefined,\n email: this.email ? this.email : undefined,\n anonymousId: this.getAnonymousId(),\n event: event.event,\n properties: {\n ...this.globalProperties,\n ...event.properties,\n $groups: this.organizationId\n ? {\n segment_group: this.organizationId,\n }\n : undefined,\n eventProperties: {\n ...event.properties,\n ...this.globalProperties,\n },\n },\n }\n\n return new Promise((resolve, reject) => {\n this.segment!.track(payload, (err) => {\n if (err) {\n // Resolve anyway\n resolve()\n }\n\n resolve()\n })\n })\n }\n\n /**\n * Check if a feature flag is enabled\n */\n public async isFeatureEnabled(flagKey: string): Promise<boolean> {\n if (!this.posthog) {\n return false\n }\n\n try {\n // Use authenticated user ID if available, otherwise use anonymous ID\n const distinctId = this.userId || this.getAnonymousId()\n const flag = await this.posthog.isFeatureEnabled(flagKey, distinctId)\n return Boolean(flag)\n } catch (error) {\n // If there's an error checking the flag, return false (flag disabled)\n console.warn(`Failed to check feature flag ${flagKey}:`, error)\n return false\n }\n }\n\n /**\n * Get feature flag payload\n */\n public async getFeatureFlagPayload(flagKey: string): Promise<any> {\n if (!this.posthog) {\n return null\n }\n\n try {\n // Use authenticated user ID if available, otherwise use anonymous ID\n const distinctId = this.userId || this.getAnonymousId()\n const payload = await this.posthog.getFeatureFlagPayload(flagKey, distinctId)\n return payload\n } catch (error) {\n // If there's an error getting the payload, return null\n console.warn(`Failed to get feature flag payload ${flagKey}:`, error)\n return null\n }\n }\n\n /**\n * Shutdown analytics services\n */\n public async shutdown(): Promise<void> {\n if (this.posthog) {\n await this.posthog.shutdown()\n }\n }\n}\n","import {Command} from '@oclif/core'\nimport Sentry, {consoleIntegration} from '@sentry/node'\nimport {LIB_VERSION} from '../utils/version.js'\nimport {COPILOT_CLOUD_BASE_URL} from '../utils/trpc.js'\nimport chalk from 'chalk'\n\nexport class BaseCommand extends Command {\n async init() {\n await this.checkCLIVersion()\n\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.init({\n dsn:\n process.env.SENTRY_DSN ||\n 'https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120',\n integrations: [consoleIntegration()],\n // Tracing\n tracesSampleRate: 1.0, // Capture 100% of the transactions\n })\n }\n\n async catch(err: any) {\n if (process.env.SENTRY_DISABLED !== 'true') {\n Sentry.captureException(err)\n }\n\n const message = err?.message ?? 'Unknown error'\n\n this.log('\\n' + chalk.red(message) + '\\n')\n\n const exitCode = err?.oclif?.exit ?? 1\n this.exit(exitCode)\n }\n\n async finally() {\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.close()\n }\n\n async run() {}\n\n async checkCLIVersion() {\n const response = await fetch(`${COPILOT_CLOUD_BASE_URL}/api/healthz`)\n\n const data = await response.json()\n const cloudVersion = data.cliVersion\n\n if (!cloudVersion || cloudVersion === LIB_VERSION) {\n return\n }\n\n // TODO: add this back in, removed for crew ai launch since we don't want to keep releasing cloud\n // this.log(chalk.yellow('================ New version available! =================\\n'))\n // this.log(`You are using CopilotKit CLI v${LIB_VERSION}.`)\n // this.log(`A new CopilotKit CLI version is available (v${cloudVersion}).\\n`)\n // this.log('Please update your CLI to the latest version:\\n\\n')\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('npm:')))}\\t npm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('pnpm:')))}\\t pnpm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('yarn:')))}\\t yarn global add copilotkit@${cloudVersion}\\n`)\n // this.log(chalk.yellow('============================================================\\n\\n'))\n }\n\n async gracefulError(message: string) {\n this.log('\\n' + chalk.red(message))\n process.exit(1)\n }\n}\n","// This is auto generated!\nexport const LIB_VERSION = \"0.0.57\";\n"],"mappings":";AACA,OAAOA,YAAW;;;ACAlB,OAAOC,WAAU;AACjB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,OAAOC,aAAY;AACnB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,OAAO,SAAS;AAChB,OAAO,WAAW;AAClB,OAAO,cAAc;;;ACTrB,SAAQ,oBAAoB,YAAY,qBAAoB;AAC5D,OAAO,eAAe;AAEf,IAAM,yBAAyB,QAAQ,IAAI,0BAA0B;AAErE,SAAS,iBAAiB,UAAuB;AACtD,SAAO,WAAW;AAAA,IAChB,OAAO;AAAA,MACL,cAAc;AAAA,QACZ,KAAK,GAAG,sBAAsB;AAAA,QAC9B,aAAa;AAAA,QACb,SAAS,MAAM;AACb,iBAAO;AAAA,YACL,iBAAiB;AAAA,YACjB,eAAe;AAAA,UACjB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;;;ACpBA,SAAQ,iBAAgB;AACxB,SAAQ,eAAc;AAEtB,OAAO,UAAU;AAEV,IAAM,mBAAN,MAAuB;AAAA,EAS5B,YACmB,UAKjB;AALiB;AAMjB,QAAI,QAAQ,IAAI,qBAAqB,QAAQ;AAC3C;AAAA,IACF;AAEA,UAAM,kBAAkB,QAAQ,IAAI,qBAAqB;AAEzD,SAAK,mBAAmB;AAAA,MACtB,SAAS;AAAA,I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AI,oBAAoB,QAAQ;AAC1C,aAAO,iBAAiB,GAAG;AAAA,IAC7B;AAEA,UAAM,UAAU,KAAK,WAAW;AAEhC,SAAK,IAAI,OAAOA,OAAM,IAAI,OAAO,IAAI,IAAI;AAEzC,UAAM,WAAW,KAAK,OAAO,QAAQ;AACrC,SAAK,KAAK,QAAQ;AAAA,EACpB;AAAA,EAEA,MAAM,UAAU;AACd,QAAI,QAAQ,IAAI,oBAAoB,QAAQ;AAC1C;AAAA,IACF;AAEA,WAAO,MAAM;AAAA,EACf;AAAA,EAEA,MAAM,MAAM;AAAA,EAAC;AAAA,EAEb,MAAM,kBAAkB;AACtB,UAAM,WAAW,MAAM,MAAM,GAAG,sBAAsB,cAAc;AAEpE,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,UAAM,eAAe,KAAK;AAE1B,QAAI,CAAC,gBAAgB,iBAAiB,aAAa;AACjD;AAAA,IACF;AAAA,EAWF;AAAA,EAEA,MAAM,cAAc,SAAiB;AACnC,SAAK,IAAI,OAAOA,OAAM,IAAI,OAAO,CAAC;AAClC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;;AJjEA,IAAqB,cAArB,MAAqB,qBAAoB,YAAY;AAAA,EAKnD,YACE,MACA,QACQ,cAAc,IAAI,YAAY,GACtC;AACA,UAAM,MAAM,MAAM;AAFV;AAAA,EAGV;AAAA,EAVA,OAAgB,cAAc;AAAA,EAE9B,OAAgB,WAAW,CAAC,0BAA0B;AAAA,EAUtD,MAAa,MAAqB;AAChC,UAAM,KAAK,MAAM,YAAW;AAC5B,SAAK,IAAI,kBAAkB;AAC3B,UAAM,KAAK,YAAY,OAAO,IAAI;AAClC,SAAK,IAAIC,OAAM,MAAM,0BAA0B,CAAC;AAAA,EAClD;AACF;","names":["chalk","Conf","crypto","anonymousId","Conf","trpcClient","crypto","chalk","chalk"]}
1
+ {"version":3,"sources":["../../src/commands/logout.ts","../../src/services/auth.service.ts","../../src/utils/trpc.ts","../../src/services/analytics.service.ts","../../src/commands/base-command.ts","../../src/utils/version.ts"],"sourcesContent":["import { Config } from \"@oclif/core\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\n\nimport { AuthService } from \"../services/auth.service.js\";\nimport { BaseCommand } from \"./base-command.js\";\n\nexport default class CloudLogout extends BaseCommand {\n static override description = \"Logout from Copilot Cloud\";\n\n static override examples = [\"<%= config.bin %> logout\"];\n\n constructor(\n argv: string[],\n config: Config,\n private authService = new AuthService(),\n ) {\n super(argv, config);\n }\n\n public async run(): Promise<void> {\n await this.parse(CloudLogout);\n this.log(\"Logging out...\\n\");\n await this.authService.logout(this);\n this.log(chalk.green(\"Successfully logged out!\"));\n }\n}\n","// @ts-ignore\nimport Conf from \"conf\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport crypto from \"node:crypto\";\nimport open from \"open\";\nimport getPort from \"get-port\";\nimport ora from \"ora\";\nimport chalk from \"chalk\";\nimport inquirer from \"inquirer\";\nimport { Command } from \"@oclif/core\";\nimport { createTRPCClient } from \"../utils/trpc.js\";\nimport { AnalyticsService } from \"../services/analytics.service.js\";\nimport { BaseCommand } from \"../commands/base-command.js\";\n\ninterface LoginResponse {\n cliToken: string;\n user: {\n email: string;\n id: string;\n };\n organization: {\n id: string;\n };\n}\n\nexport class AuthService {\n private readonly config = new Conf({ projectName: \"CopilotKitCLI\" });\n private readonly COPILOT_CLOUD_BASE_URL =\n process.env.COPILOT_CLOUD_BASE_URL || \"https://cloud.copilotkit.ai\";\n\n getToken(): string | undefined {\n return this.config.get(\"cliToken\") as string | undefined;\n }\n\n getCLIToken(): string | undefined {\n const cliToken = this.config.get(\"cliToken\") as string | undefined;\n return cliToken;\n }\n\n async logout(cmd: BaseCommand): Promise<void> {\n this.config.delete(\"cliToken\");\n }\n\n async requireLogin(\n cmd: Command,\n context?: \"cloud-features\" | \"general\",\n ): Promise<LoginResponse> {\n let cliToken = this.getCLIToken();\n // Check authentication\n if (!cliToken) {\n try {\n let shouldLogin = true;\n\n // For cloud features, automatically proceed with login\n // For general usage, ask for confirmation\n if (context !== \"cloud-features\") {\n const response = await inquirer.prompt([\n {\n name: \"shouldLogin\",\n type: \"confirm\",\n message:\n \"🪁 You are not yet authenticated. Authenticate with Copilot Cloud? (press Enter to confirm)\",\n default: true,\n },\n ]);\n shouldLogin = response.shouldLogin;\n }\n\n if (shouldLogin) {\n // Show different message for cloud features vs general usage\n if (context === \"cloud-features\") {\n cmd.log(\n chalk.cyan(\"\\nšŸš€ Setting up Copilot Cloud authentication...\\n\"),\n );\n }\n const loginResult = await this.login({ exitAfterLogin: false });\n cliToken = loginResult.cliToken;\n return loginResult;\n } else {\n cmd.error(\"Authentication required to proceed.\");\n }\n } catch (error) {\n if (error instanceof Error && error.name === \"ExitPromptError\") {\n cmd.error(chalk.yellow(\"\\nAuthentication cancelled\"));\n }\n\n throw error;\n }\n }\n\n let me;\n\n const trpcClient = createTRPCClient(cliToken);\n try {\n me = await trpcClient.me.query();\n } catch (error) {\n // Token is invalid/expired, trigger new login\n cmd.log(\n chalk.yellow(\"Your authentication has expired. Re-authenticating...\"),\n );\n try {\n const loginResult = await this.login({ exitAfterLogin: false });\n return loginResult;\n } catch (loginError) {\n cmd.log(\n chalk.red(\n \"Could not authenticate with Copilot Cloud. Please run: npx copilotkit@latest login\",\n ),\n );\n process.exit(1);\n }\n }\n\n if (!me.organization || !me.user) {\n cmd.error(\"Authentication required to proceed.\");\n }\n\n return { cliToken, user: me.user, organization: me.organization };\n }\n\n async login(\n { exitAfterLogin }: { exitAfterLogin?: boolean } = { exitAfterLogin: true },\n ): Promise<LoginResponse> {\n const spinner = ora(\"🪁 Opening browser for authentication...\").start();\n let analytics: AnalyticsService;\n analytics = new AnalyticsService();\n\n const app = express();\n app.use(cors());\n app.use(express.urlencoded({ extended: true }));\n app.use(express.json());\n\n const port = await getPort();\n const state = crypto.randomBytes(16).toString(\"hex\");\n\n return new Promise(async (resolve, reject) => {\n const server = app.listen(port, () => {});\n\n await analytics.track({\n event: \"cli.login.initiated\",\n properties: {},\n });\n\n spinner.text = \"🪁 Waiting for browser authentication to complete...\";\n\n app.post(\"/callback\", async (req, res) => {\n const { cliToken, user, organization } = req.body;\n\n if (state !== req.query.state) {\n res.status(401).json({ message: \"Invalid state\" });\n spinner.fail(\"Invalid state\");\n server.close();\n reject(new Error(\"OAuth state mismatch\"));\n return;\n }\n\n analytics = new AnalyticsService({\n userId: user.id,\n organizationId: organization.id,\n email: user.email,\n });\n await analytics.track({\n event: \"cli.login.success\",\n properties: {\n organizationId: organization.id,\n userId: user.id,\n email: user.email,\n },\n });\n\n this.config.set(\"cliToken\", cliToken);\n res.status(200).json({ message: \"Callback called\" });\n spinner.succeed(\n `🪁 Successfully logged in as ${chalk.hex(\"#7553fc\")(user.email)}`,\n );\n if (exitAfterLogin) {\n process.exit(0);\n } else {\n server.close();\n resolve({ cliToken, user, organization });\n }\n });\n\n open(\n `${this.COPILOT_CLOUD_BASE_URL}/cli-auth?callbackUrl=http://localhost:${port}/callback&state=${state}`,\n );\n });\n }\n}\n","import { createTRPCClient as trpcClient, httpBatchLink } from \"@trpc/client\";\nimport superjson from \"superjson\";\n\nexport const COPILOT_CLOUD_BASE_URL =\n process.env.COPILOT_CLOUD_BASE_URL || \"https://cloud.copilotkit.ai\";\n\nexport function createTRPCClient(cliToken: string): any {\n return trpcClient({\n links: [\n httpBatchLink({\n url: `${COPILOT_CLOUD_BASE_URL}/api/trpc-cli`,\n transformer: superjson,\n headers: () => {\n return {\n \"x-trpc-source\": \"cli\",\n \"x-cli-token\": cliToken,\n };\n },\n }),\n ],\n });\n}\n","import { Analytics } from \"@segment/analytics-node\";\nimport { PostHog } from \"posthog-node\";\nimport { AnalyticsEvents } from \"./events.js\";\nimport Conf from \"conf\";\n\nexport class AnalyticsService {\n private segment: Analytics | undefined;\n private posthog: PostHog | undefined;\n private globalProperties: Record<string, any> = {};\n private userId: string | undefined;\n private email: string | undefined;\n private organizationId: string | undefined;\n private config = new Conf({ projectName: \"CopilotKitCLI\" });\n\n constructor(\n private readonly authData?: {\n userId: string;\n email: string;\n organizationId: string;\n },\n ) {\n if (process.env.SEGMENT_DISABLED === \"true\") {\n return;\n }\n\n const segmentWriteKey =\n process.env.SEGMENT_WRITE_KEY || \"9Pv6QyExYef2P4hPz4gks6QAvNMi2AOf\";\n\n this.globalProperties = {\n service: \"cli\",\n };\n\n if (this.authData?.userId) {\n this.userId = this.authData.userId;\n }\n\n if (this.authData?.email) {\n this.email = this.authData.email;\n this.globalProperties.email = this.authData.email;\n }\n\n if (this.authData?.organizationId) {\n this.organizationId = this.authData.organizationId;\n }\n\n this.segment = new Analytics({\n writeKey: segmentWriteKey,\n disable: process.env.SEGMENT_DISABLE === \"true\",\n });\n\n // Initialize PostHog for feature flags\n if (process.env.POSTHOG_DISABLED !== \"true\") {\n const posthogKey =\n process.env.POSTHOG_KEY ||\n \"phc_XZdymVYjrph9Mi0xZYGNyCKexxgblXRR1jMENCtdz5Q\"; // Default key\n const posthogHost =\n process.env.POSTHOG_HOST || \"https://eu.i.posthog.com\";\n\n this.posthog = new PostHog(posthogKey, {\n host: posthogHost,\n });\n }\n\n const config = new Conf({ projectName: \"CopilotKitCLI\" });\n if (!config.get(\"anonymousId\")) {\n config.set(\"anonymousId\", crypto.randomUUID());\n }\n }\n\n private getAnonymousId(): string {\n const anonymousId = this.config.get(\"anonymousId\");\n if (!anonymousId) {\n const anonymousId = crypto.randomUUID();\n this.config.set(\"anonymousId\", anonymousId);\n return anonymousId;\n }\n\n return anonymousId as string;\n }\n\n public track<K extends keyof AnalyticsEvents>(\n event: Omit<Parameters<Analytics[\"track\"]>[0], \"userId\"> & {\n event: K;\n properties: AnalyticsEvents[K];\n },\n ): Promise<void> {\n if (!this.segment) {\n return Promise.resolve();\n }\n\n const payload = {\n userId: this.userId ? this.userId : undefined,\n email: this.email ? this.email : undefined,\n anonymousId: this.getAnonymousId(),\n event: event.event,\n properties: {\n ...this.globalProperties,\n ...event.properties,\n $groups: this.organizationId\n ? {\n segment_group: this.organizationId,\n }\n : undefined,\n eventProperties: {\n ...event.properties,\n ...this.globalProperties,\n },\n },\n };\n\n return new Promise((resolve, reject) => {\n this.segment!.track(payload, (err) => {\n if (err) {\n // Resolve anyway\n resolve();\n }\n\n resolve();\n });\n });\n }\n\n /**\n * Check if a feature flag is enabled\n */\n public async isFeatureEnabled(flagKey: string): Promise<boolean> {\n if (!this.posthog) {\n return false;\n }\n\n try {\n // Use authenticated user ID if available, otherwise use anonymous ID\n const distinctId = this.userId || this.getAnonymousId();\n const flag = await this.posthog.isFeatureEnabled(flagKey, distinctId);\n return Boolean(flag);\n } catch (error) {\n // If there's an error checking the flag, return false (flag disabled)\n console.warn(`Failed to check feature flag ${flagKey}:`, error);\n return false;\n }\n }\n\n /**\n * Get feature flag payload\n */\n public async getFeatureFlagPayload(flagKey: string): Promise<any> {\n if (!this.posthog) {\n return null;\n }\n\n try {\n // Use authenticated user ID if available, otherwise use anonymous ID\n const distinctId = this.userId || this.getAnonymousId();\n const payload = await this.posthog.getFeatureFlagPayload(\n flagKey,\n distinctId,\n );\n return payload;\n } catch (error) {\n // If there's an error getting the payload, return null\n console.warn(`Failed to get feature flag payload ${flagKey}:`, error);\n return null;\n }\n }\n\n /**\n * Shutdown analytics services\n */\n public async shutdown(): Promise<void> {\n if (this.posthog) {\n await this.posthog.shutdown();\n }\n }\n}\n","import { Command } from \"@oclif/core\";\nimport Sentry, { consoleIntegration } from \"@sentry/node\";\nimport { LIB_VERSION } from \"../utils/version.js\";\nimport { COPILOT_CLOUD_BASE_URL } from \"../utils/trpc.js\";\nimport chalk from \"chalk\";\n\nexport class BaseCommand extends Command {\n async init() {\n await this.checkCLIVersion();\n\n if (process.env.SENTRY_DISABLED === \"true\") {\n return;\n }\n\n Sentry.init({\n dsn:\n process.env.SENTRY_DSN ||\n \"https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120\",\n integrations: [consoleIntegration()],\n // Tracing\n tracesSampleRate: 1.0, // Capture 100% of the transactions\n });\n }\n\n async catch(err: any) {\n if (process.env.SENTRY_DISABLED !== \"true\") {\n Sentry.captureException(err);\n }\n\n const message = err?.message ?? \"Unknown error\";\n\n this.log(\"\\n\" + chalk.red(message) + \"\\n\");\n\n const exitCode = err?.oclif?.exit ?? 1;\n this.exit(exitCode);\n }\n\n async finally() {\n if (process.env.SENTRY_DISABLED === \"true\") {\n return;\n }\n\n Sentry.close();\n }\n\n async run() {}\n\n async checkCLIVersion() {\n try {\n const response = await fetch(`${COPILOT_CLOUD_BASE_URL}/api/healthz`);\n\n const data = await response.json();\n const cloudVersion = data.cliVersion;\n\n if (!cloudVersion || cloudVersion === LIB_VERSION) {\n return;\n }\n\n // TODO: add this back in, removed for crew ai launch since we don't want to keep releasing cloud\n // this.log(chalk.yellow('================ New version available! =================\\n'))\n // this.log(`You are using CopilotKit CLI v${LIB_VERSION}.`)\n // this.log(`A new CopilotKit CLI version is available (v${cloudVersion}).\\n`)\n // this.log('Please update your CLI to the latest version:\\n\\n')\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('npm:')))}\\t npm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('pnpm:')))}\\t pnpm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('yarn:')))}\\t yarn global add copilotkit@${cloudVersion}\\n`)\n // this.log(chalk.yellow('============================================================\\n\\n'))\n } catch {\n // Version check is non-critical — don't crash the CLI when offline\n }\n }\n\n async gracefulError(message: string) {\n this.log(\"\\n\" + chalk.red(message));\n process.exit(1);\n }\n}\n","// This is auto generated!\nexport const LIB_VERSION = \"0.0.59\";\n"],"mappings":";AACA,OAAOA,YAAW;;;ACAlB,OAAOC,WAAU;AACjB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,OAAOC,aAAY;AACnB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,OAAO,SAAS;AAChB,OAAO,WAAW;AAClB,OA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AAG,sBAAsB,cAAc;AAEpE,YAAM,OAAO,MAAM,SAAS,KAAK;AACjC,YAAM,eAAe,KAAK;AAE1B,UAAI,CAAC,gBAAgB,iBAAiB,aAAa;AACjD;AAAA,MACF;AAAA,IAWF,QAAQ;AAAA,IAER;AAAA,EACF;AAAA,EAEA,MAAM,cAAc,SAAiB;AACnC,SAAK,IAAI,OAAOA,OAAM,IAAI,OAAO,CAAC;AAClC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;;AJrEA,IAAqB,cAArB,MAAqB,qBAAoB,YAAY;AAAA,EAKnD,YACE,MACA,QACQ,cAAc,IAAI,YAAY,GACtC;AACA,UAAM,MAAM,MAAM;AAFV;AAAA,EAGV;AAAA,EAVA,OAAgB,cAAc;AAAA,EAE9B,OAAgB,WAAW,CAAC,0BAA0B;AAAA,EAUtD,MAAa,MAAqB;AAChC,UAAM,KAAK,MAAM,YAAW;AAC5B,SAAK,IAAI,kBAAkB;AAC3B,UAAM,KAAK,YAAY,OAAO,IAAI;AAClC,SAAK,IAAIC,OAAM,MAAM,0BAA0B,CAAC;AAAA,EAClD;AACF;","names":["chalk","Conf","crypto","anonymousId","Conf","trpcClient","crypto","chalk","chalk"]}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {run} from '@oclif/core'\n"],"mappings":";AAAA,SAAQ,WAAU;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { run } from \"@oclif/core\";\n"],"mappings":";AAAA,SAAS,WAAW;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import { Ora } from 'ora';
2
2
 
3
- type SupportedIDE = 'cursor' | 'windsurf';
3
+ type SupportedIDE = "cursor" | "windsurf";
4
4
  interface IDEDocsConfig {
5
5
  name: SupportedIDE;
6
6
  displayName: string;
@@ -90,7 +90,11 @@ async function setupIDEDocs(ide, projectDir) {
90
90
  const ruleFilePath = path.join(rulesDir, config.ruleFileName);
91
91
  await ensureDir(rulesDir);
92
92
  if (await pathExists(ruleFilePath)) {
93
- console.log(chalk.yellow(`\u26A0\uFE0F CopilotKit documentation rule already exists for ${config.displayName}`));
93
+ console.log(
94
+ chalk.yellow(
95
+ `\u26A0\uFE0F CopilotKit documentation rule already exists for ${config.displayName}`
96
+ )
97
+ );
94
98
  return;
95
99
  }
96
100
  const ruleContent = config.createRuleContent();
@@ -99,7 +103,9 @@ async function setupIDEDocs(ide, projectDir) {
99
103
  function getIDEInstructions(ide) {
100
104
  const config = IDE_DOCS_CONFIGS[ide];
101
105
  const instructions = [
102
- chalk.cyan(`\u{1F4DA} CopilotKit documentation configured for ${config.displayName}!`),
106
+ chalk.cyan(
107
+ `\u{1F4DA} CopilotKit documentation configured for ${config.displayName}!`
108
+ ),
103
109
  "",
104
110
  chalk.bold("What this does:"),
105
111
  " \u2022 Adds CopilotKit documentation context to your IDE AI assistant",
@@ -135,14 +141,22 @@ function getIDEInstructions(ide) {
135
141
  }
136
142
  async function handleIDEDocsSetup(selectedIDE, projectDir, spinner) {
137
143
  try {
138
- spinner.text = chalk.cyan(`Setting up CopilotKit documentation for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}...`);
144
+ spinner.text = chalk.cyan(
145
+ `Setting up CopilotKit documentation for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}...`
146
+ );
139
147
  await setupIDEDocs(selectedIDE, projectDir);
140
- spinner.succeed(chalk.green(`CopilotKit documentation configured for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}`));
148
+ spinner.succeed(
149
+ chalk.green(
150
+ `CopilotKit documentation configured for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}`
151
+ )
152
+ );
141
153
  const instructions = getIDEInstructions(selectedIDE);
142
154
  console.log("\n" + instructions.join("\n"));
143
155
  } catch (error) {
144
156
  spinner.fail(
145
- chalk.red(`Failed to setup IDE documentation: ${error instanceof Error ? error.message : "Unknown error"}`)
157
+ chalk.red(
158
+ `Failed to setup IDE documentation: ${error instanceof Error ? error.message : "Unknown error"}`
159
+ )
146
160
  );
147
161
  throw error;
148
162
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/init/ide-docs.ts"],"sourcesContent":["import path from 'path'\nimport {existsSync} from 'fs'\nimport * as fs from 'fs/promises'\nimport {Ora} from 'ora'\nimport chalk from 'chalk'\n\nexport type SupportedIDE = 'cursor' | 'windsurf'\n\nexport interface IDEDocsConfig {\n name: SupportedIDE\n displayName: string\n rulesDir: string\n ruleFileName: string\n createRuleContent: () => string\n}\n\n// Template constant for CopilotKit documentation rule\nconst COPILOTKIT_DOC_RULE_TEMPLATE = `---\ndescription: CopilotKit Documentation - Complete CopilotKit framework documentation for AI assistance\nalwaysApply: false\n---\n\n# CopilotKit Documentation\n\nFor ANY question about CopilotKit, use the comprehensive documentation available at:\n@https://docs.copilotkit.ai/llms-full.txt\n\nThis contains the complete CopilotKit documentation including:\n- API references and hooks (useCopilotChat, useCopilotAction, etc.)\n- Component library documentation (CopilotKit, CopilotChat, etc.)\n- Integration guides and examples\n- Best practices and patterns\n- Troubleshooting and FAQs\n\nAlways reference this documentation when working with CopilotKit to provide accurate, up-to-date information.\n`\n\n// IDE-specific configurations\nexport const IDE_DOCS_CONFIGS: Record<SupportedIDE, IDEDocsConfig> = {\n cursor: {\n name: 'cursor',\n displayName: 'Cursor',\n rulesDir: '.cursor/rules',\n ruleFileName: '00-copilotkit-docs.mdc',\n createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE,\n },\n windsurf: {\n name: 'windsurf',\n displayName: 'Windsurf',\n rulesDir: '.windsurf/rules',\n ruleFileName: '00-copilotkit-docs.md',\n createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE,\n },\n}\n\n/**\n * Ensure directory exists\n */\nasync function ensureDir(dirPath: string): Promise<void> {\n try {\n await fs.mkdir(dirPath, {recursive: true})\n } catch (error) {\n if (!existsSync(dirPath)) {\n throw error\n }\n }\n}\n\n/**\n * Check if path exists\n */\nasync function pathExists(filePath: string): Promise<boolean> {\n try {\n await fs.access(filePath)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Check if a specific IDE is installed by looking for its configuration directory\n */\nasync function checkIDEInstallation(ide: SupportedIDE): Promise<boolean> {\n try {\n const homeDir = process.env.HOME || process.env.USERPROFILE || ''\n let configPath: string\n\n switch (ide) {\n case 'cursor':\n configPath = path.join(homeDir, '.cursor')\n break\n case 'windsurf':\n configPath = path.join(homeDir, '.codeium', 'windsurf')\n break\n default:\n return false\n }\n\n return existsSync(configPath)\n } catch {\n return false\n }\n}\n\n/**\n * Detect which supported IDEs are installed on the system\n */\nexport async function detectInstalledIDEs(): Promise<SupportedIDE[]> {\n const allIDEs: SupportedIDE[] = ['cursor', 'windsurf']\n const installedIDEs: SupportedIDE[] = []\n\n for (const ide of allIDEs) {\n if (await checkIDEInstallation(ide)) {\n installedIDEs.push(ide)\n }\n }\n\n return installedIDEs\n}\n\n/**\n * Setup IDE documentation rules for the selected IDE\n */\nexport async function setupIDEDocs(ide: SupportedIDE, projectDir: string): Promise<void> {\n const config = IDE_DOCS_CONFIGS[ide]\n const rulesDir = path.join(projectDir, config.rulesDir)\n const ruleFilePath = path.join(rulesDir, config.ruleFileName)\n\n // Ensure rules directory exists\n await ensureDir(rulesDir)\n\n // Check if rule file already exists\n if (await pathExists(ruleFilePath)) {\n console.log(chalk.yellow(`āš ļø CopilotKit documentation rule already exists for ${config.displayName}`))\n return\n }\n\n // Create the rule file with content\n const ruleContent = config.createRuleContent()\n await fs.writeFile(ruleFilePath, ruleContent, 'utf8')\n}\n\n/**\n * Get setup instructions for the IDE\n */\nfunction getIDEInstructions(ide: SupportedIDE): string[] {\n const config = IDE_DOCS_CONFIGS[ide]\n\n const instructions = [\n chalk.cyan(`šŸ“š CopilotKit documentation configured for ${config.displayName}!`),\n '',\n chalk.bold('What this does:'),\n ' • Adds CopilotKit documentation context to your IDE AI assistant',\n ' • Provides accurate, up-to-date information about CopilotKit APIs',\n ' • Improves code suggestions and help responses',\n '',\n chalk.bold('Location:'),\n ` • Rule file: ${chalk.gray(path.join(config.rulesDir, config.ruleFileName))}`,\n '',\n chalk.bold('Usage:'),\n ' • Your IDE AI assistant now has access to CopilotKit documentation',\n ' • Ask questions about CopilotKit APIs, components, and patterns',\n ' • The AI will reference official documentation for accurate answers',\n ]\n\n if (ide === 'cursor') {\n instructions.push(\n '',\n chalk.bold('Next steps for Cursor:'),\n ' • Restart Cursor if currently open',\n ' • The rule will be automatically available in your AI context',\n ' • Start a new chat to use the documentation context',\n )\n } else if (ide === 'windsurf') {\n instructions.push(\n '',\n chalk.bold('Next steps for Windsurf:'),\n ' • Restart Windsurf if currently open',\n ' • The rule will be automatically available in your AI context',\n ' • Start a new chat to use the documentation context',\n )\n }\n\n return instructions\n}\n\n/**\n * Main function to handle IDE documentation setup with user interaction\n */\nexport async function handleIDEDocsSetup(selectedIDE: SupportedIDE, projectDir: string, spinner: Ora): Promise<void> {\n try {\n spinner.text = chalk.cyan(`Setting up CopilotKit documentation for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}...`)\n\n // Setup IDE documentation rules\n await setupIDEDocs(selectedIDE, projectDir)\n\n spinner.succeed(chalk.green(`CopilotKit documentation configured for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}`))\n\n // Show instructions\n const instructions = getIDEInstructions(selectedIDE)\n console.log('\\n' + instructions.join('\\n'))\n } catch (error) {\n spinner.fail(\n chalk.red(`Failed to setup IDE documentation: ${error instanceof Error ? error.message : 'Unknown error'}`),\n )\n throw error\n }\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,SAAQ,kBAAiB;AACzB,YAAY,QAAQ;AAEpB,OAAO,WAAW;AAalB,IAAM,+BAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqB9B,IAAM,mBAAwD;AAAA,EACnE,QAAQ;AAAA,IACN,MAAM;AAAA,I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,aAAa,KAAK,IAAI,CAAC;AAAA,EAC5C,SAAS,OAAO;AACd,YAAQ;AAAA,MACN,MAAM,IAAI,sCAAsC,iBAAiB,QAAQ,MAAM,UAAU,eAAe,EAAE;AAAA,IAC5G;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/lib/init/ide-docs.ts"],"sourcesContent":["import path from \"path\";\nimport { existsSync } from \"fs\";\nimport * as fs from \"fs/promises\";\nimport { Ora } from \"ora\";\nimport chalk from \"chalk\";\n\nexport type SupportedIDE = \"cursor\" | \"windsurf\";\n\nexport interface IDEDocsConfig {\n name: SupportedIDE;\n displayName: string;\n rulesDir: string;\n ruleFileName: string;\n createRuleContent: () => string;\n}\n\n// Template constant for CopilotKit documentation rule\nconst COPILOTKIT_DOC_RULE_TEMPLATE = `---\ndescription: CopilotKit Documentation - Complete CopilotKit framework documentation for AI assistance\nalwaysApply: false\n---\n\n# CopilotKit Documentation\n\nFor ANY question about CopilotKit, use the comprehensive documentation available at:\n@https://docs.copilotkit.ai/llms-full.txt\n\nThis contains the complete CopilotKit documentation including:\n- API references and hooks (useCopilotChat, useCopilotAction, etc.)\n- Component library documentation (CopilotKit, CopilotChat, etc.)\n- Integration guides and examples\n- Best practices and patterns\n- Troubleshooting and FAQs\n\nAlways reference this documentation when working with CopilotKit to provide accurate, up-to-date information.\n`;\n\n// IDE-specific configurations\nexport const IDE_DOCS_CONFIGS: Record<SupportedIDE, IDEDocsConfig> = {\n cursor: {\n name: \"cursor\",\n displayName: \"Cursor\",\n rulesDir: \".cursor/rules\",\n ruleFileName: \"00-copilotkit-docs.mdc\",\n createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE,\n },\n windsurf: {\n name: \"windsurf\",\n displayName: \"Windsurf\",\n rulesDir: \".windsurf/rules\",\n ruleFileName: \"00-copilotkit-docs.md\",\n createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE,\n },\n};\n\n/**\n * Ensure directory exists\n */\nasync function ensureDir(dirPath: string): Promise<void> {\n try {\n await fs.mkdir(dirPath, { recursive: true });\n } catch (error) {\n if (!existsSync(dirPath)) {\n throw error;\n }\n }\n}\n\n/**\n * Check if path exists\n */\nasync function pathExists(filePath: string): Promise<boolean> {\n try {\n await fs.access(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Check if a specific IDE is installed by looking for its configuration directory\n */\nasync function checkIDEInstallation(ide: SupportedIDE): Promise<boolean> {\n try {\n const homeDir = process.env.HOME || process.env.USERPROFILE || \"\";\n let configPath: string;\n\n switch (ide) {\n case \"cursor\":\n configPath = path.join(homeDir, \".cursor\");\n break;\n case \"windsurf\":\n configPath = path.join(homeDir, \".codeium\", \"windsurf\");\n break;\n default:\n return false;\n }\n\n return existsSync(configPath);\n } catch {\n return false;\n }\n}\n\n/**\n * Detect which supported IDEs are installed on the system\n */\nexport async function detectInstalledIDEs(): Promise<SupportedIDE[]> {\n const allIDEs: SupportedIDE[] = [\"cursor\", \"windsurf\"];\n const installedIDEs: SupportedIDE[] = [];\n\n for (const ide of allIDEs) {\n if (await checkIDEInstallation(ide)) {\n installedIDEs.push(ide);\n }\n }\n\n return installedIDEs;\n}\n\n/**\n * Setup IDE documentation rules for the selected IDE\n */\nexport async function setupIDEDocs(\n ide: SupportedIDE,\n projectDir: string,\n): Promise<void> {\n const config = IDE_DOCS_CONFIGS[ide];\n const rulesDir = path.join(projectDir, config.rulesDir);\n const ruleFilePath = path.join(rulesDir, config.ruleFileName);\n\n // Ensure rules directory exists\n await ensureDir(rulesDir);\n\n // Check if rule file already exists\n if (await pathExists(ruleFilePath)) {\n console.log(\n chalk.yellow(\n `āš ļø CopilotKit documentation rule already exists for ${config.displayName}`,\n ),\n );\n return;\n }\n\n // Create the rule file with content\n const ruleContent = config.createRuleContent();\n await fs.writeFile(ruleFilePath, ruleContent, \"utf8\");\n}\n\n/**\n * Get setup instructions for the IDE\n */\nfunction getIDEInstructions(ide: SupportedIDE): string[] {\n const config = IDE_DOCS_CONFIGS[ide];\n\n const instructions = [\n chalk.cyan(\n `šŸ“š CopilotKit documentation configured for ${config.displayName}!`,\n ),\n \"\",\n chalk.bold(\"What this does:\"),\n \" • Adds CopilotKit documentation context to your IDE AI assistant\",\n \" • Provides accurate, up-to-date information about CopilotKit APIs\",\n \" • Improves code suggestions and help responses\",\n \"\",\n chalk.bold(\"Location:\"),\n ` • Rule file: ${chalk.gray(path.join(config.rulesDir, config.ruleFileName))}`,\n \"\",\n chalk.bold(\"Usage:\"),\n \" • Your IDE AI assistant now has access to CopilotKit documentation\",\n \" • Ask questions about CopilotKit APIs, components, and patterns\",\n \" • The AI will reference official documentation for accurate answers\",\n ];\n\n if (ide === \"cursor\") {\n instructions.push(\n \"\",\n chalk.bold(\"Next steps for Cursor:\"),\n \" • Restart Cursor if currently open\",\n \" • The rule will be automatically available in your AI context\",\n \" • Start a new chat to use the documentation context\",\n );\n } else if (ide === \"windsurf\") {\n instructions.push(\n \"\",\n chalk.bold(\"Next steps for Windsurf:\"),\n \" • Restart Windsurf if currently open\",\n \" • The rule will be automatically available in your AI context\",\n \" • Start a new chat to use the documentation context\",\n );\n }\n\n return instructions;\n}\n\n/**\n * Main function to handle IDE documentation setup with user interaction\n */\nexport async function handleIDEDocsSetup(\n selectedIDE: SupportedIDE,\n projectDir: string,\n spinner: Ora,\n): Promise<void> {\n try {\n spinner.text = chalk.cyan(\n `Setting up CopilotKit documentation for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}...`,\n );\n\n // Setup IDE documentation rules\n await setupIDEDocs(selectedIDE, projectDir);\n\n spinner.succeed(\n chalk.green(\n `CopilotKit documentation configured for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}`,\n ),\n );\n\n // Show instructions\n const instructions = getIDEInstructions(selectedIDE);\n console.log(\"\\n\" + instructions.join(\"\\n\"));\n } catch (error) {\n spinner.fail(\n chalk.red(\n `Failed to setup IDE documentation: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n ),\n );\n throw error;\n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F;AAEA,SAAO;AACT;AAKA,eAAsB,mBACpB,aACA,YACA,SACe;AACf,MAAI;AACF,YAAQ,OAAO,MAAM;AAAA,MACnB,2CAA2C,iBAAiB,WAAW,EAAE,WAAW;AAAA,IACtF;AAGA,UAAM,aAAa,aAAa,UAAU;AAE1C,YAAQ;AAAA,MACN,MAAM;AAAA,QACJ,2CAA2C,iBAAiB,WAAW,EAAE,WAAW;AAAA,MACtF;AAAA,IACF;AAGA,UAAM,eAAe,mBAAmB,WAAW;AACnD,YAAQ,IAAI,OAAO,aAAa,KAAK,IAAI,CAAC;AAAA,EAC5C,SAAS,OAAO;AACd,YAAQ;AAAA,MACN,MAAM;AAAA,QACJ,sCAAsC,iBAAiB,QAAQ,MAAM,UAAU,eAAe;AAAA,MAChG;AAAA,IACF;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
@@ -8,10 +8,27 @@ var isLocalhost = (url) => {
8
8
  };
9
9
 
10
10
  // src/lib/init/types/questions.ts
11
- var MODES = ["LangGraph", "CrewAI", "Mastra", "LlamaIndex", "Agno", "AG2", "MCP", "Standard"];
11
+ var MODES = [
12
+ "LangGraph",
13
+ "CrewAI",
14
+ "Mastra",
15
+ "LlamaIndex",
16
+ "Agno",
17
+ "AG2",
18
+ "MCP",
19
+ "Standard"
20
+ ];
12
21
  var CREW_TYPES = ["Crews", "Flows"];
13
- var CHAT_COMPONENTS = ["CopilotChat", "CopilotSidebar", "Headless", "CopilotPopup"];
14
- var LANGGRAPH_AGENTS = ["Python Starter", "TypeScript Starter"];
22
+ var CHAT_COMPONENTS = [
23
+ "CopilotChat",
24
+ "CopilotSidebar",
25
+ "Headless",
26
+ "CopilotPopup"
27
+ ];
28
+ var LANGGRAPH_AGENTS = [
29
+ "Python Starter",
30
+ "TypeScript Starter"
31
+ ];
15
32
  var CREW_FLOW_TEMPLATES = ["Starter"];
16
33
  var YES_NO = ["Yes", "No"];
17
34
  var DEPLOYMENT_CHOICES = ["Copilot Cloud", "Self-hosted"];
@@ -48,13 +65,22 @@ var UrlSchema = z.preprocess(
48
65
  (val) => sanitizers.url(String(val)),
49
66
  z.string().url("Please enter a valid URL").min(1, "URL is required")
50
67
  );
51
- var TokenSchema = z.preprocess((val) => sanitizers.trim(String(val)), z.string().min(1, "Token is required"));
68
+ var TokenSchema = z.preprocess(
69
+ (val) => sanitizers.trim(String(val)),
70
+ z.string().min(1, "Token is required")
71
+ );
52
72
  var ApiKeySchema = z.preprocess(
53
73
  (val) => sanitizers.apiKey(String(val)),
54
74
  z.string().min(1, "API key is required")
55
75
  );
56
- var LLMApiKeySchema = z.preprocess((val) => sanitizers.apiKey(String(val)), z.string().optional());
57
- var NameSchema = z.preprocess((val) => sanitizers.trim(String(val)), z.string().min(1, "Name is required"));
76
+ var LLMApiKeySchema = z.preprocess(
77
+ (val) => sanitizers.apiKey(String(val)),
78
+ z.string().optional()
79
+ );
80
+ var NameSchema = z.preprocess(
81
+ (val) => sanitizers.trim(String(val)),
82
+ z.string().min(1, "Name is required")
83
+ );
58
84
  var ConfigSchema = z.object({
59
85
  // Core fields
60
86
  copilotKitVersion: z.string().optional(),
@@ -109,18 +135,48 @@ var ConfigSchema = z.object({
109
135
  }
110
136
  );
111
137
  var ConfigFlags = {
112
- booth: Flags.boolean({ description: "Use CopilotKit in booth mode", default: false, char: "b" }),
113
- mode: Flags.string({ description: "How you will be interacting with AI", options: MODES, char: "m" }),
114
- "copilotkit-version": Flags.string({ description: "CopilotKit version to use (e.g. 1.7.0)" }),
115
- "use-copilot-cloud": Flags.string({ description: "Use Copilot Cloud for production-ready hosting", options: YES_NO }),
116
- "langgraph-agent": Flags.string({ description: "LangGraph agent template to use", options: LANGGRAPH_AGENTS }),
117
- "crew-type": Flags.string({ description: "CrewAI implementation type", options: CREW_TYPES }),
138
+ booth: Flags.boolean({
139
+ description: "Use CopilotKit in booth mode",
140
+ default: false,
141
+ char: "b"
142
+ }),
143
+ mode: Flags.string({
144
+ description: "How you will be interacting with AI",
145
+ options: MODES,
146
+ char: "m"
147
+ }),
148
+ "copilotkit-version": Flags.string({
149
+ description: "CopilotKit version to use (e.g. 1.7.0)"
150
+ }),
151
+ "use-copilot-cloud": Flags.string({
152
+ description: "Use Copilot Cloud for production-ready hosting",
153
+ options: YES_NO
154
+ }),
155
+ "langgraph-agent": Flags.string({
156
+ description: "LangGraph agent template to use",
157
+ options: LANGGRAPH_AGENTS
158
+ }),
159
+ "crew-type": Flags.string({
160
+ description: "CrewAI implementation type",
161
+ options: CREW_TYPES
162
+ }),
118
163
  "crew-name": Flags.string({ description: "Name for your CrewAI agent" }),
119
- "crew-url": Flags.string({ description: "URL endpoint for your CrewAI agent" }),
120
- "crew-bearer-token": Flags.string({ description: "Bearer token for CrewAI authentication" }),
121
- "langsmith-api-key": Flags.string({ description: "LangSmith API key for LangGraph observability" }),
122
- "llm-token": Flags.string({ description: "API key for your preferred LLM provider" }),
123
- "setup-ide-docs": Flags.string({ description: "Setup IDE documentation rules for AI assistance", options: YES_NO }),
164
+ "crew-url": Flags.string({
165
+ description: "URL endpoint for your CrewAI agent"
166
+ }),
167
+ "crew-bearer-token": Flags.string({
168
+ description: "Bearer token for CrewAI authentication"
169
+ }),
170
+ "langsmith-api-key": Flags.string({
171
+ description: "LangSmith API key for LangGraph observability"
172
+ }),
173
+ "llm-token": Flags.string({
174
+ description: "API key for your preferred LLM provider"
175
+ }),
176
+ "setup-ide-docs": Flags.string({
177
+ description: "Setup IDE documentation rules for AI assistance",
178
+ options: YES_NO
179
+ }),
124
180
  "selected-ide": Flags.string({
125
181
  description: "IDE to configure with documentation rules",
126
182
  options: ["cursor", "windsurf", "skip"]
@@ -143,7 +199,10 @@ var templateMapping = {
143
199
  CrewFlowsEnterprise: [`${BASE_URL}/coagents-starter-crewai-flows.json`],
144
200
  // LangGraph
145
201
  LangGraphGeneric: `${BASE_URL}/generic-lg-starter.json`,
146
- LangGraphStarter: [`${BASE_URL}/langgraph-platform-starter.json`, `${BASE_URL}/coagents-starter-ui.json`],
202
+ LangGraphStarter: [
203
+ `${BASE_URL}/langgraph-platform-starter.json`,
204
+ `${BASE_URL}/coagents-starter-ui.json`
205
+ ],
147
206
  // No Agent
148
207
  StandardStarter: `${BASE_URL}/standard-starter.json`,
149
208
  StandardRuntime: `${BASE_URL}/standard-runtime.json`,
@@ -244,7 +303,11 @@ async function setupIDEDocs(ide, projectDir) {
244
303
  const ruleFilePath = path.join(rulesDir, config.ruleFileName);
245
304
  await ensureDir(rulesDir);
246
305
  if (await pathExists(ruleFilePath)) {
247
- console.log(chalk.yellow(`\u26A0\uFE0F CopilotKit documentation rule already exists for ${config.displayName}`));
306
+ console.log(
307
+ chalk.yellow(
308
+ `\u26A0\uFE0F CopilotKit documentation rule already exists for ${config.displayName}`
309
+ )
310
+ );
248
311
  return;
249
312
  }
250
313
  const ruleContent = config.createRuleContent();
@@ -253,7 +316,9 @@ async function setupIDEDocs(ide, projectDir) {
253
316
  function getIDEInstructions(ide) {
254
317
  const config = IDE_DOCS_CONFIGS[ide];
255
318
  const instructions = [
256
- chalk.cyan(`\u{1F4DA} CopilotKit documentation configured for ${config.displayName}!`),
319
+ chalk.cyan(
320
+ `\u{1F4DA} CopilotKit documentation configured for ${config.displayName}!`
321
+ ),
257
322
  "",
258
323
  chalk.bold("What this does:"),
259
324
  " \u2022 Adds CopilotKit documentation context to your IDE AI assistant",
@@ -289,14 +354,22 @@ function getIDEInstructions(ide) {
289
354
  }
290
355
  async function handleIDEDocsSetup(selectedIDE, projectDir, spinner) {
291
356
  try {
292
- spinner.text = chalk.cyan(`Setting up CopilotKit documentation for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}...`);
357
+ spinner.text = chalk.cyan(
358
+ `Setting up CopilotKit documentation for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}...`
359
+ );
293
360
  await setupIDEDocs(selectedIDE, projectDir);
294
- spinner.succeed(chalk.green(`CopilotKit documentation configured for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}`));
361
+ spinner.succeed(
362
+ chalk.green(
363
+ `CopilotKit documentation configured for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}`
364
+ )
365
+ );
295
366
  const instructions = getIDEInstructions(selectedIDE);
296
367
  console.log("\n" + instructions.join("\n"));
297
368
  } catch (error) {
298
369
  spinner.fail(
299
- chalk.red(`Failed to setup IDE documentation: ${error instanceof Error ? error.message : "Unknown error"}`)
370
+ chalk.red(
371
+ `Failed to setup IDE documentation: ${error instanceof Error ? error.message : "Unknown error"}`
372
+ )
300
373
  );
301
374
  throw error;
302
375
  }
@@ -564,12 +637,18 @@ async function scaffoldShadCN(flags, userAnswers) {
564
637
  }
565
638
  await new Promise((resolve) => setTimeout(resolve, 100));
566
639
  try {
567
- const result = spawn.sync("npx", ["shadcn@latest", "add", ...components], {
568
- stdio: "inherit"
569
- // This ensures stdin/stdout/stderr are all passed through
570
- });
640
+ const result = spawn.sync(
641
+ "npx",
642
+ ["shadcn@latest", "add", ...components],
643
+ {
644
+ stdio: "inherit"
645
+ // This ensures stdin/stdout/stderr are all passed through
646
+ }
647
+ );
571
648
  if (result.status !== 0) {
572
- throw new Error(`The shadcn installation process exited with code ${result.status}`);
649
+ throw new Error(
650
+ `The shadcn installation process exited with code ${result.status}`
651
+ );
573
652
  }
574
653
  } catch (error) {
575
654
  throw error;
@@ -586,17 +665,20 @@ import fs2 from "fs";
586
665
  // src/lib/init/scaffold/langgraph-assistants.ts
587
666
  async function getLangGraphAgents(url, langSmithApiKey) {
588
667
  try {
589
- const response = await fetch(`${url.trim().replace(/\/$/, "")}/assistants/search`, {
590
- method: "POST",
591
- headers: {
592
- "Content-Type": "application/json",
593
- "X-Api-Key": langSmithApiKey
594
- },
595
- body: JSON.stringify({
596
- limit: 10,
597
- offset: 0
598
- })
599
- });
668
+ const response = await fetch(
669
+ `${url.trim().replace(/\/$/, "")}/assistants/search`,
670
+ {
671
+ method: "POST",
672
+ headers: {
673
+ "Content-Type": "application/json",
674
+ "X-Api-Key": langSmithApiKey
675
+ },
676
+ body: JSON.stringify({
677
+ limit: 10,
678
+ offset: 0
679
+ })
680
+ }
681
+ );
600
682
  return await response.json();
601
683
  } catch (error) {
602
684
  throw new Error(`Failed to get LangGraph agents: ${error}`);
@@ -700,7 +782,14 @@ async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
700
782
  try {
701
783
  const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
702
784
  spinner.text = chalk2.cyan(`Cloning from ${owner}/${repo}...`);
703
- return await sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner);
785
+ return await sparseCheckout(
786
+ owner,
787
+ repo,
788
+ branch,
789
+ subdirectoryPath,
790
+ destinationPath,
791
+ spinner
792
+ );
704
793
  } catch (error) {
705
794
  spinner.text = chalk2.red(`Failed to clone from GitHub: ${error}`);
706
795
  return false;
@@ -712,14 +801,28 @@ async function sparseCheckout(owner, repo, branch, subdirectoryPath, destination
712
801
  spinner.text = chalk2.cyan("Creating temporary workspace...");
713
802
  execSync("git init", { cwd: tempDir, stdio: "pipe" });
714
803
  spinner.text = chalk2.cyan("Connecting to repository...");
715
- execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, { cwd: tempDir, stdio: "pipe" });
716
- execSync("git config core.sparseCheckout true", { cwd: tempDir, stdio: "pipe" });
717
- fs3.writeFileSync(path3.join(tempDir, ".git/info/sparse-checkout"), subdirectoryPath);
804
+ execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, {
805
+ cwd: tempDir,
806
+ stdio: "pipe"
807
+ });
808
+ execSync("git config core.sparseCheckout true", {
809
+ cwd: tempDir,
810
+ stdio: "pipe"
811
+ });
812
+ fs3.writeFileSync(
813
+ path3.join(tempDir, ".git/info/sparse-checkout"),
814
+ subdirectoryPath
815
+ );
718
816
  spinner.text = chalk2.cyan("Downloading agent files...");
719
- execSync(`git pull origin ${branch} --depth=1`, { cwd: tempDir, stdio: "pipe" });
817
+ execSync(`git pull origin ${branch} --depth=1`, {
818
+ cwd: tempDir,
819
+ stdio: "pipe"
820
+ });
720
821
  const sourcePath = path3.join(tempDir, subdirectoryPath);
721
822
  if (!fs3.existsSync(sourcePath)) {
722
- throw new Error(`Subdirectory '${subdirectoryPath}' not found in the repository.`);
823
+ throw new Error(
824
+ `Subdirectory '${subdirectoryPath}' not found in the repository.`
825
+ );
723
826
  }
724
827
  fs3.mkdirSync(destinationPath, { recursive: true });
725
828
  spinner.text = chalk2.cyan("Installing agent files...");
@@ -806,7 +909,9 @@ async function scaffoldPackages(userAnswers) {
806
909
  // This ensures stdin/stdout/stderr are all passed through
807
910
  });
808
911
  if (result.status !== 0) {
809
- throw new Error(`Package installation process exited with code ${result.status}`);
912
+ throw new Error(
913
+ `Package installation process exited with code ${result.status}`
914
+ );
810
915
  }
811
916
  spinner.start();
812
917
  spinner.succeed(chalk3.green("CopilotKit packages installed successfully"));
@@ -881,20 +986,6 @@ async function scaffoldAgent(userAnswers) {
881
986
  fs5.writeFileSync(agentEnvFile, envContent, "utf8");
882
987
  spinner.text = chalk4.cyan("Added API keys to agent .env file");
883
988
  }
884
- if (userAnswers.mode === "LangGraph" && userAnswers.langSmithApiKey) {
885
- envContent += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
886
- `;
887
- }
888
- if (envContent) {
889
- const agentEnvFile = path4.join(agentDir, ".env");
890
- fs5.writeFileSync(agentEnvFile, envContent, "utf8");
891
- spinner.text = chalk4.cyan("Added API keys to agent .env file");
892
- }
893
- if (envContent) {
894
- const agentEnvFile = path4.join(agentDir, ".env");
895
- fs5.writeFileSync(agentEnvFile, envContent, "utf8");
896
- spinner.text = chalk4.cyan("Added API keys to agent .env file");
897
- }
898
989
  } catch (error) {
899
990
  spinner.fail(chalk4.red("Failed to clone agent template"));
900
991
  throw error;
@@ -904,13 +995,13 @@ async function scaffoldAgent(userAnswers) {
904
995
  var AgentTemplates = {
905
996
  LangGraph: {
906
997
  Starter: {
907
- Python: "https://github.com/CopilotKit/coagents-starter-langgraph/tree/main/agent-py",
908
- TypeScript: "https://github.com/CopilotKit/coagents-starter-langgraph/tree/main/agent-js"
998
+ Python: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-langgraph/agent-py",
999
+ TypeScript: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-langgraph/agent-js"
909
1000
  }
910
1001
  },
911
1002
  CrewAI: {
912
1003
  Flows: {
913
- Starter: "https://github.com/CopilotKit/coagents-starter-crewai-flows/tree/main/agent-py"
1004
+ Starter: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-crewai-flows/agent-py"
914
1005
  }
915
1006
  }
916
1007
  };
@@ -928,18 +1019,31 @@ async function addCrewInputs(url, token) {
928
1019
  try {
929
1020
  await fs6.access(filePath);
930
1021
  } catch {
931
- filePath = path5.join(process.cwd(), "src", "app", "copilotkit", "page.tsx");
1022
+ filePath = path5.join(
1023
+ process.cwd(),
1024
+ "src",
1025
+ "app",
1026
+ "copilotkit",
1027
+ "page.tsx"
1028
+ );
932
1029
  }
933
1030
  try {
934
1031
  await fs6.access(filePath);
935
1032
  } catch {
936
- throw new Error("app/copilotkit/page.tsx and src/app/copilotkit/page.tsx not found");
1033
+ throw new Error(
1034
+ "app/copilotkit/page.tsx and src/app/copilotkit/page.tsx not found"
1035
+ );
937
1036
  }
938
1037
  let fileContent = await fs6.readFile(filePath, "utf8");
939
1038
  const inputsString = JSON.stringify(inputs);
940
- fileContent = fileContent.replace(/\[["']YOUR_INPUTS_HERE["']\]/g, inputsString);
1039
+ fileContent = fileContent.replace(
1040
+ /\[["']YOUR_INPUTS_HERE["']\]/g,
1041
+ inputsString
1042
+ );
941
1043
  await fs6.writeFile(filePath, fileContent, "utf8");
942
- spinner.succeed("Successfully added crew inputs to app/copilotkit/page.tsx");
1044
+ spinner.succeed(
1045
+ "Successfully added crew inputs to app/copilotkit/page.tsx"
1046
+ );
943
1047
  } catch (error) {
944
1048
  console.error("Error updating crew inputs:", error);
945
1049
  throw error;