MCPcopy Index your code
hub / github.com/Stevenic/codepilot / run

Function run

lib/codepilot-cli.js:25–269  ·  view source on GitHub ↗

* Defines the commands supported by the Codepilot CLI.

()

Source from the content-addressed store, hash-verified

23 * Defines the commands supported by the Codepilot CLI.
24 */
25function run() {
26 return __awaiter(this, void 0, void 0, function* () {
27 // prettier-ignore
28 const args = yield (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
29 .scriptName('codepilot')
30 .command('$0', 'chat mode', {}, () => __awaiter(this, void 0, void 0, function* () {
31 // Ensure index exists and has keys
32 const index = new CodeIndex_1.CodeIndex();
33 if (!(yield index.isCreated())) {
34 console.log(internals_1.Colorize.output([
35 `We need to first create an index before you can chat with Codepilot.`,
36 `You'll need to provide an OpenAI API key and a source folder to index.`,
37 `You can create an OpenAI API key at https://platform.openai.com/account/api-keys.`,
38 `A paid account is recommended but OpenAI will give you $5 in free credits to get started.`,
39 `Once you have your OpenAI API key, you can create a new index by running:\n`,
40 `codepilot create --key <api key> --source <source folder> [--source <additional source folder>]\n`,
41 `By default, all files under your source folders will be included in the index.`,
42 `If you'd only like certain file extensions to be indexed, you can add the "--extension <included extensions> [--extension <additional extension>]" option.`,
43 `Once the index has finished building, you can start chatting with Codepilot by running:\n`,
44 `codepilot\n`,
45 ].join(`\n`)));
46 return;
47 }
48 if (!(yield index.hasKeys())) {
49 console.log(internals_1.Colorize.output([
50 `A Codepilot index was found but you haven't configured your personal OpenAI key.`,
51 `You'll need to provide an OpenAI API key before you can continue.`,
52 `You can create an OpenAI API key at https://platform.openai.com/account/api-keys.`,
53 `A paid account is recommended but OpenAI will give you $5 in free credits to get started.`,
54 `Once you have your OpenAI API key, you can configure your local index to use that key by running:\n`,
55 `codepilot set --key <api key>\n`,
56 `Once you've configured your personal key, you can start chatting with Codepilot by running:\n`,
57 `codepilot\n`,
58 ].join(`\n`)));
59 return;
60 }
61 // Load index
62 yield index.load();
63 // Start a Codepilot chat session
64 const codepilot = new Codepilot_1.Codepilot(index);
65 (0, functions_1.registerFunctions)(codepilot);
66 yield codepilot.chat();
67 }))
68 .command('create', `creates a new code index`, (yargs) => {
69 return yargs
70 .option('key', {
71 alias: 'k',
72 describe: 'OpenAI API key to use for generating embeddings and querying the model.',
73 type: 'string'
74 })
75 .option('model', {
76 alias: 'm',
77 describe: 'OpenAI model to use for queries. Defaults to "gpt-3.5-turbo-16k".',
78 type: 'string',
79 default: 'gpt-3.5-turbo-16k'
80 })
81 .option('source', {
82 alias: 's',

Callers

nothing calls this directly

Calls 14

isCreatedMethod · 0.95
hasKeysMethod · 0.95
loadMethod · 0.95
chatMethod · 0.95
createMethod · 0.95
rebuildMethod · 0.95
deleteMethod · 0.95
addMethod · 0.95
removeMethod · 0.95
setKeysMethod · 0.95
setConfigMethod · 0.95
getOptimalConfigFunction · 0.70

Tested by

no test coverage detected