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

Method rebuild

lib/CodeIndex.js:229–262  ·  view source on GitHub ↗

* Rebuilds the code index.

()

Source from the content-addressed store, hash-verified

227 * Rebuilds the code index.
228 */
229 rebuild() {
230 return __awaiter(this, void 0, void 0, function* () {
231 if (!(yield this.isCreated())) {
232 throw new Error('Index has not been created yet. Please run `codepilot create` first.');
233 }
234 if (!(yield this.hasKeys())) {
235 throw new Error("A local vectra.keys file couldn't be found. Please run `codepilot set --key <your OpenAI key>`.");
236 }
237 // Create fresh index
238 const index = yield this.load();
239 if (yield index.isCatalogCreated()) {
240 yield index.deleteIndex();
241 }
242 yield index.createIndex();
243 // Index files
244 const fetcher = new vectra_1.FileFetcher();
245 for (const source of this._config.sources) {
246 yield fetcher.fetch(source, (uri, text, docType) => __awaiter(this, void 0, void 0, function* () {
247 // Ignore binary files
248 if (IGNORED_FILES.includes(path.extname(uri))) {
249 return true;
250 }
251 // Ignore any disallowed extensions
252 if (this._config.extensions && docType && !this._config.extensions.includes(docType)) {
253 return true;
254 }
255 // Upsert document
256 console.log(internals_1.Colorize.progress(`adding: ${uri}`));
257 yield index.upsertDocument(uri, text, docType);
258 return true;
259 }));
260 }
261 });
262 }
263 // LLM-REGION
264 /**
265 * Removes sources and extensions from the index.

Callers 1

runFunction · 0.95

Calls 5

isCreatedMethod · 0.95
hasKeysMethod · 0.95
loadMethod · 0.95
progressMethod · 0.45
upsertDocumentMethod · 0.45

Tested by

no test coverage detected