MCPcopy Create free account
hub / github.com/Stevenic/codepilot / create

Method create

src/CodeIndex.ts:168–198  ·  view source on GitHub ↗

* Creates a new code index. * @param keys OpenAI keys to use. * @param config Source code index configuration.

(keys: OpenAIKeys, config: CodeIndexConfig)

Source from the content-addressed store, hash-verified

166 * @param config Source code index configuration.
167 */
168 public async create(keys: OpenAIKeys, config: CodeIndexConfig): Promise<void> {
169 // Delete folder if it exists
170 if (await fs.stat(this.folderPath).then(() => true).catch(() => false)) {
171 await fs.rm(this.folderPath, { recursive: true });
172 }
173
174 // Create folder
175 await fs.mkdir(this.folderPath);
176
177 try {
178 // Create config file
179 await fs.writeFile(path.join(this.folderPath, 'config.json'), JSON.stringify(config));
180
181 // Create keys file
182 await fs.writeFile(path.join(this.folderPath, 'vectra.keys'), JSON.stringify(keys));
183
184 // Create .gitignore file
185 await fs.writeFile(path.join(this.folderPath, '.gitignore'), 'vectra.keys');
186 this._config = config;
187 this._keys = keys;
188
189 // Create index
190 const index = await this.load();
191 await index.createIndex();
192 } catch(err: unknown) {
193 this._config = undefined;
194 this._keys = undefined;
195 await fs.rm(this.folderPath, { recursive: true });
196 throw new Error(`Error creating index: ${(err as any).toString()}`);
197 }
198 }
199
200 // LLM-REGION
201

Callers 1

runFunction · 0.95

Calls 1

loadMethod · 0.95

Tested by

no test coverage detected