(options: GenerateOptions)
| 57 | } |
| 58 | |
| 59 | async function generateCommand(options: GenerateOptions): Promise<void> { |
| 60 | trackEvent("command", { name: "generate" }); |
| 61 | log.blank(); |
| 62 | |
| 63 | let accessToken: string | null = null; |
| 64 | const tokens = loadTokens(); |
| 65 | if (tokens && !isTokenExpired(tokens)) { |
| 66 | accessToken = tokens.access_token; |
| 67 | } else { |
| 68 | log.info("Authentication required. Logging in..."); |
| 69 | log.blank(); |
| 70 | accessToken = await performLogin(); |
| 71 | if (!accessToken) { |
| 72 | log.error("Login failed. Please try again."); |
| 73 | return; |
| 74 | } |
| 75 | log.blank(); |
| 76 | } |
| 77 | |
| 78 | const initSpinner = ora().start(); |
| 79 | const quota = await getSkillQuota(accessToken); |
| 80 | |
| 81 | if (quota.error) { |
| 82 | initSpinner.fail(pc.red("Failed to initialize")); |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | if (quota.tier !== "unlimited" && quota.remaining < 1) { |
| 87 | initSpinner.fail(pc.red("Weekly skill generation limit reached")); |
| 88 | log.blank(); |
| 89 | console.log( |
| 90 | ` You've used ${pc.bold(pc.white(quota.used.toString()))}/${pc.bold(pc.white(quota.limit.toString()))} skill generations this week.` |
| 91 | ); |
| 92 | console.log( |
| 93 | ` Your quota resets on ${pc.yellow(new Date(quota.resetDate!).toLocaleDateString())}.` |
| 94 | ); |
| 95 | log.blank(); |
| 96 | if (quota.tier === "free") { |
| 97 | console.log( |
| 98 | ` ${pc.yellow("Tip:")} Upgrade to Pro for ${pc.bold("10")} generations per week.` |
| 99 | ); |
| 100 | console.log(` Visit ${pc.green("https://context7.com/dashboard")} to upgrade.`); |
| 101 | } |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | initSpinner.stop(); |
| 106 | initSpinner.clear(); |
| 107 | |
| 108 | console.log(pc.bold("What should your agent become an expert at?\n")); |
| 109 | console.log( |
| 110 | pc.dim( |
| 111 | "Skills should encode best practices, constraints, and decision-making —\nnot step-by-step tutorials or one-off tasks.\n" |
| 112 | ) |
| 113 | ); |
| 114 | console.log(pc.yellow("Examples:")); |
| 115 | // prettier-ignore |
| 116 | { |
no test coverage detected