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

Method upsertDocument

lib/CodeIndex.js:348–366  ·  view source on GitHub ↗

* Adds a document to the index. * @param path Path to the document to add.

(path)

Source from the content-addressed store, hash-verified

346 * @param path Path to the document to add.
347 */
348 upsertDocument(path) {
349 return __awaiter(this, void 0, void 0, function* () {
350 if (!(yield this.isCreated())) {
351 throw new Error('Index has not been created yet. Please run `codepilot create` first.');
352 }
353 if (!(yield this.hasKeys())) {
354 throw new Error("A local vectra.keys file couldn't be found. Please run `codepilot set --key <your OpenAI key>`.");
355 }
356 // Ensure index is loaded
357 const index = yield this.load();
358 // Fetch document
359 const fetcher = new vectra_1.FileFetcher();
360 yield fetcher.fetch(path, (uri, text, docType) => __awaiter(this, void 0, void 0, function* () {
361 // Upsert document
362 yield index.upsertDocument(uri, text, docType);
363 return true;
364 }));
365 });
366 }
367}
368exports.CodeIndex = CodeIndex;
369//# sourceMappingURL=CodeIndex.js.map

Callers 2

rebuildMethod · 0.45
addCreateFileFunction · 0.45

Calls 3

isCreatedMethod · 0.95
hasKeysMethod · 0.95
loadMethod · 0.95

Tested by

no test coverage detected